aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java171
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java79
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java61
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java8
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontFactory.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLExtensions.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java19
-rw-r--r--src/jogl/classes/com/jogamp/opengl/JoglVersion.java26
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Quaternion.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java9
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java90
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/DebugGL2.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DebugGL3.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DebugGL3bc.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DebugGL4.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DebugGLES2.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java7
-rw-r--r--src/jogl/classes/javax/media/opengl/GLBase.java138
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java395
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDebugMessage.java74
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java18
-rw-r--r--src/jogl/classes/javax/media/opengl/GLPipelineFactory.java20
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java370
-rw-r--r--src/jogl/classes/javax/media/opengl/TraceGL2.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/TraceGL3.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/TraceGL3bc.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/TraceGL4.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/TraceGLES2.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java77
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp1
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp1
-rw-r--r--src/jogl/classes/jogamp/opengl/Debug.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java10
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java191
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java10
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/GLVersionNumber.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java51
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java123
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java42
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java32
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java23
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java1940
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java74
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java550
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java23
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java17
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java53
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java284
-rw-r--r--src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java31
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java10
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java4
-rw-r--r--src/jogl/native/GLDebugMessageHandler.c8
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java7
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java5
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/package.html94
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java13
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java11
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Point.java13
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java11
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java25
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java11
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java26
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/Debug.java9
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java31
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/Display.java83
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorMode.java119
-rw-r--r--src/newt/classes/com/jogamp/newt/Screen.java62
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java34
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java27
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java92
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/util/EDTUtil.java58
-rw-r--r--src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java11
-rw-r--r--src/newt/classes/jogamp/newt/Debug.java9
-rw-r--r--src/newt/classes/jogamp/newt/DefaultEDTUtil.java115
-rw-r--r--src/newt/classes/jogamp/newt/DisplayImpl.java186
-rw-r--r--src/newt/classes/jogamp/newt/MonitorDeviceImpl.java12
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java62
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java220
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java135
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR11.java26
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR13.java63
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java58
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java63
-rw-r--r--src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java170
-rw-r--r--src/newt/native/KeyEvent.h2
-rw-r--r--src/newt/native/WindowsWindow.c3
-rw-r--r--src/newt/native/X11RandR11.c2
-rw-r--r--src/newt/native/X11Window.c159
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java69
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java34
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java31
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java63
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java33
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java57
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/RedSquareShader.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.fp11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.vp5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.vp5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsequence_xxx.fp1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java59
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java89
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java191
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_gimpexp.pngbin0 -> 1927 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_orig.pngbin0 -> 2129 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java)6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java)45
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00bNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java)7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java244
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java)101
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java)47
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java)13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java)144
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java250
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java)175
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java69
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java61
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/UITestCase.java123
239 files changed, 6920 insertions, 3509 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java
index 5334d45cf..262fed934 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java
@@ -57,10 +57,31 @@ import java.util.Set;
public class BuildComposablePipeline {
- public static final int GEN_DEBUG = 1 << 0; // default
- public static final int GEN_TRACE = 1 << 1; // default
+ /** <p>Default: true</p>. */
+ public static final int GEN_DEBUG = 1 << 0;
+ /** <p>Default: true</p>. */
+ public static final int GEN_TRACE = 1 << 1;
+ /** <p>Default: false</p>. */
public static final int GEN_CUSTOM = 1 << 2;
+ /**
+ * By extra command-line argument: <code>prolog_xor_downstream</code>.
+ * <p>
+ * If true, either prolog (if exist) is called or downstream's method, but not both.
+ * By default, both methods would be called.
+ * </p>
+ * <p>Default: false</p>
+ */
public static final int GEN_PROLOG_XOR_DOWNSTREAM = 1 << 3;
+ /**
+ * By extra command-line argument: <code>gl_identity_by_assignable_class</code>.
+ * <p>
+ * If true, implementation does not utilize downstream's <code>isGL*()</code>
+ * implementation, but determines whether the GL profile is matched by interface inheritance.
+ * </p>
+ * <p>Default: false</p>
+ */
+ public static final int GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS = 1 << 4;
+
int mode;
private String outputDir;
private String outputPackage;
@@ -71,7 +92,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;
@@ -110,8 +131,12 @@ public class BuildComposablePipeline {
classDownstream = getClass(args[4]);
mode = GEN_CUSTOM;
if (args.length > 5) {
- if (args[5].equals("prolog_xor_downstream")) {
- mode |= GEN_PROLOG_XOR_DOWNSTREAM;
+ for(int i=5; i<args.length; i++) {
+ if (args[i].equals("prolog_xor_downstream")) {
+ mode |= GEN_PROLOG_XOR_DOWNSTREAM;
+ } else if (args[i].equals("gl_identity_by_assignable_class")) {
+ mode |= GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS;
+ }
}
}
} else {
@@ -119,7 +144,7 @@ public class BuildComposablePipeline {
outputName = null; // TBD ..
classPrologOpt = null;
classDownstream = classToComposeAround;
- mode = GEN_DEBUG | GEN_TRACE;
+ mode = GEN_DEBUG | GEN_TRACE ;
}
BuildComposablePipeline composer =
@@ -155,7 +180,7 @@ public class BuildComposablePipeline {
}
try {
- hasStackOverflow =
+ hasGL2ES1StackOverflow = hasImmediateMode &&
(classToComposeAround.getField("GL_STACK_OVERFLOW") != null);
} catch (Exception e) {
}
@@ -167,16 +192,16 @@ public class BuildComposablePipeline {
*/
public void emit() throws IOException {
- List<Method> publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods());
+ final List<Method> publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods());
- Set<PlainMethod> publicMethodsPlain = new HashSet<PlainMethod>();
+ final Set<PlainMethod> publicMethodsPlain = new HashSet<PlainMethod>();
for (Iterator<Method> iter = publicMethodsRaw.iterator(); iter.hasNext();) {
- Method method = iter.next();
+ final Method method = iter.next();
// Don't hook methods which aren't real GL methods,
// such as the synthetic "isGL2ES2" "getGL2ES2"
- String name = method.getName();
+ final String name = method.getName();
boolean runHooks = name.startsWith("gl");
- if (!name.startsWith("getGL") && !name.startsWith("isGL") && !name.equals("toString")) {
+ if ( !name.startsWith("getGL") && !name.startsWith("isGL") && !name.equals("getDownstreamGL") && !name.equals("toString") ) {
publicMethodsPlain.add(new PlainMethod(method, runHooks));
}
}
@@ -602,12 +627,17 @@ public class BuildComposablePipeline {
* Emits one of the isGL* methods.
*/
protected void emitGLIsMethod(PrintWriter output, String type) {
- output.println(" public boolean is" + type + "() {");
- Class<?> clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type);
- if (clazz.isAssignableFrom(baseInterfaceClass)) {
- output.println(" return true;");
+ output.println(" @Override");
+ output.println(" public final boolean is" + type + "() {");
+ if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) {
+ final Class<?> clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type);
+ if (clazz.isAssignableFrom(baseInterfaceClass)) {
+ output.println(" return true;");
+ } else {
+ output.println(" return false;");
+ }
} else {
- output.println(" return false;");
+ output.println(" return " + getDownstreamObjectName() + ".is" + type + "();");
}
output.println(" }");
}
@@ -624,27 +654,57 @@ 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();");
+ 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(" }");
+ } else {
+ emitGLIsMethod(output, "GLES");
+ }
+ output.println(" @Override");
+ output.println(" public final boolean isGL4core() {");
+ output.println(" return " + getDownstreamObjectName() + ".isGL4core();");
+ output.println(" }");
+ output.println(" @Override");
+ output.println(" public final boolean isGL3core() {");
+ output.println(" return " + getDownstreamObjectName() + ".isGL3core();");
output.println(" }");
- output.println(" public boolean isGLES2Compatible() {");
+ output.println(" @Override");
+ output.println(" public final boolean isGLcore() {");
+ output.println(" return " + getDownstreamObjectName() + ".isGLcore();");
+ output.println(" }");
+ output.println(" @Override");
+ output.println(" public final boolean isGLES2Compatible() {");
output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();");
output.println(" }");
+ output.println(" @Override");
+ output.println(" public final boolean isGLES3Compatible() {");
+ output.println(" return " + getDownstreamObjectName() + ".isGLES3Compatible();");
+ output.println(" }");
}
/**
* Emits one of the getGL* methods.
*/
protected void emitGLGetMethod(PrintWriter output, String type) {
- 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;");
+ output.println(" @Override");
+ output.println(" public final javax.media.opengl." + type + " get" + type + "() {");
+ if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) {
+ final 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\");");
+ }
} else {
- output.println(" throw new GLException(\"Not a " + type + " implementation\");");
+ output.println(" return " + getDownstreamObjectName() + ".get" + type + "();");
}
output.println(" }");
}
@@ -661,10 +721,18 @@ 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(" public GLProfile getGLProfile() {");
+ output.println(" @Override");
+ output.println(" public final GL getDownstreamGL() throws GLException {");
+ output.println(" return " + getDownstreamObjectName() + ";");
+ output.println(" }");
+ output.println(" @Override");
+ output.println(" public final GLProfile getGLProfile() {");
output.println(" return " + getDownstreamObjectName() + ".getGLProfile();");
output.println(" }");
}
@@ -870,9 +938,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\");");
@@ -902,15 +970,20 @@ public class BuildComposablePipeline {
}
protected void emitClassDocComment(PrintWriter output) {
- output.println("/** <P> Composable pipeline which wraps an underlying {@link GL} implementation,");
- output.println(" providing error checking after each OpenGL method call. If an error occurs,");
- output.println(" causes a {@link GLException} to be thrown at exactly the point of failure.");
- output.println(" Sample code which installs this pipeline: </P>");
- output.println();
- output.println("<PRE>");
- output.println(" GL gl = drawable.setGL(new DebugGL(drawable.getGL()));");
- output.println("</PRE>");
- output.println("*/");
+ output.println("/**");
+ output.println(" * <p>");
+ output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,");
+ output.println(" * providing error checking after each OpenGL method call. If an error occurs,");
+ output.println(" * causes a {@link GLException} to be thrown at exactly the point of failure.");
+ output.println(" * </p>");
+ output.println(" * <p>");
+ output.println(" * Sample code which installs this pipeline:");
+ output.println(" * <pre>");
+ output.println(" * gl = drawable.setGL(new DebugGL(drawable.getGL()));");
+ output.println(" * </pre>");
+ output.println(" * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}");
+ output.println(" * </p>");
+ output.println(" */");
}
protected boolean hasPreDownstreamCallHook(Method m) {
@@ -1038,14 +1111,20 @@ public class BuildComposablePipeline {
}
protected void emitClassDocComment(PrintWriter output) {
- output.println("/** <P> Composable pipeline which wraps an underlying {@link GL} implementation,");
- output.println(" providing tracing information to a user-specified {@link java.io.PrintStream}");
- output.println(" before and after each OpenGL method call. Sample code which installs this pipeline: </P>");
- output.println();
- output.println("<PRE>");
- output.println(" GL gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
- output.println("</PRE>");
- output.println("*/");
+ output.println("/**");
+ output.println(" * <p>");
+ output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,");
+ output.println(" * providing tracing information to a user-specified {@link java.io.PrintStream}");
+ output.println(" * before and after each OpenGL method call.");
+ output.println(" * </p>");
+ output.println(" * <p>");
+ output.println(" * Sample code which installs this pipeline:");
+ output.println(" * <pre>");
+ output.println(" * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
+ output.println(" * </pre>");
+ output.println(" * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}");
+ output.println(" * </p>");
+ output.println(" */");
}
protected boolean hasPreDownstreamCallHook(Method m) {
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<String> glHeaders = new ArrayList<String>();
private Set<String> ignoredExtensions = new HashSet<String>();
+ private Set<String> forcedExtensions = new HashSet<String>();
private Set<String> extensionsRenamedIntoCore = new HashSet<String>();
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<String> extensionNames = glInfo.getExtension(symbol);
- if(null!=extensionNames) {
- for(Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) {
- String extensionName = i.next();
- if (extensionName != null && ignoredExtensions.contains(extensionName)) {
+ final Set<String> extensionNames = glInfo.getExtension(symbol);
+ if( null != extensionNames ) {
+ boolean ignoredExtension = false;
+ for(Iterator<String> 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<String> 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<String> extensionNames = glInfo.getExtension(symbol);
+ if( null != extensionNames ) {
+ for(Iterator<String> 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("<code> ");
+ writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding));
+ writer.print(" </code> ");
+
newComment.append("<br>Part of ");
if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, binding.getAliasedNames())) {
if (glEmitter.getGLConfig().getAllowNonGLExtensions()) {
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/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/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 9fe74ee97..023a8a1aa 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -71,17 +71,18 @@ public class GLRendererQuirks {
/**
* Non compliant GL context due to a buggy implementation not suitable for use.
* <p>
- * Mesa >= 9.0 (?), Intel driver, OpenGL 3.1 compatibility context is not compliant:
- * <pre>
- * GL_RENDERER: 'Mesa .* Intel(R) Sandybridge Desktop'
- * </pre>
+ * Currently, Mesa >= 9.1.3 (may extend back as far as 9.0) OpenGL 3.1 compatibility
+ * context is not compliant. Most programs will give completely broken output (or no
+ * output at all. For now, this context is not trusted.
* </p>
- * <p>
- * Mesa >= 9.0 (?), AMD driver, OpenGL 3.1 core and compatibility context is not compliant:
- * <pre>
- * GL_RENDERER: 'Gallium 0.4 on AMD RS880'
- * </pre>
+ * The above has been confirmed for the following Mesa 9.* GL_RENDERER strings:
+ * <ul>
+ * <li>Mesa .* Intel(R) Sandybridge Desktop</li>
+ * <li>Gallium 0.4 on AMD RS880</li>
+ * </ul>
* </p>
+ * <p>
+ * It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought.
*/
public static final int GLNonCompliant = 6;
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
index 6cd02b749..1f0189aa3 100644
--- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
+++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
@@ -130,7 +130,7 @@ public class JoglVersion extends JogampVersion {
public static StringBuilder getGLInfo(GL gl, StringBuilder sb) {
return getGLInfo(gl, sb, false);
}
- public static StringBuilder getGLInfo(GL gl, StringBuilder sb, boolean withCapabilitiesInfo) {
+ public static StringBuilder getGLInfo(GL gl, StringBuilder sb, boolean withCapabilitiesAndExtensionInfo) {
AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface()
.getGraphicsConfiguration().getScreen().getDevice();
if(null==sb) {
@@ -143,15 +143,19 @@ public class JoglVersion extends JogampVersion {
GLProfile.glAvailabilityToString(device, sb, "\t", 1);
sb.append(Platform.getNewline());
- sb = getGLStrings(gl, sb);
+ sb = getGLStrings(gl, sb, withCapabilitiesAndExtensionInfo);
- if( withCapabilitiesInfo ) {
+ if( withCapabilitiesAndExtensionInfo ) {
sb = getAllAvailableCapabilitiesInfo(device, sb);
}
return sb;
}
- public static StringBuilder getGLStrings(GL gl, StringBuilder sb) {
+ public static StringBuilder getGLStrings(GL gl, StringBuilder sb) {
+ return getGLStrings(gl, sb, true);
+ }
+
+ public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) {
if(null==sb) {
sb = new StringBuilder();
}
@@ -177,14 +181,20 @@ public class JoglVersion extends JogampVersion {
sb.append(", version: ").append(gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)).append(" / ").append(ctx.getGLSLVersionNumber());
}
sb.append(Platform.getNewline());
- sb.append("GL_EXTENSIONS ").append(ctx.getGLExtensionCount());
+ sb.append("GL FBO: basic ").append(gl.hasBasicFBOSupport()).append(", full ").append(gl.hasFullFBOSupport());
sb.append(Platform.getNewline());
- sb.append(" ").append(ctx.getGLExtensionsString());
+ sb.append("GL_EXTENSIONS ").append(ctx.getGLExtensionCount());
sb.append(Platform.getNewline());
+ if( withExtensions ) {
+ sb.append(" ").append(ctx.getGLExtensionsString());
+ sb.append(Platform.getNewline());
+ }
sb.append("GLX_EXTENSIONS ").append(ctx.getPlatformExtensionCount());
sb.append(Platform.getNewline());
- sb.append(" ").append(ctx.getPlatformExtensionsString());
- sb.append(Platform.getNewline());
+ if( withExtensions ) {
+ sb.append(" ").append(ctx.getPlatformExtensionsString());
+ sb.append(Platform.getNewline());
+ }
sb.append(VersionUtil.SEPERATOR);
return sb;
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index d5ffe2da4..c6bf44f6d 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -330,20 +330,8 @@ public class Quaternion {
}
/**
- * Check if this quaternion is empty, ie (0,0,0,1)
- *
- * @return true if empty, false otherwise
- * @deprecated use {@link #isIdentity()} instead
- */
- @Deprecated
- public boolean isEmpty() {
- if (w == 1 && x == 0 && y == 0 && z == 0)
- return true;
- return false;
- }
-
- /**
- * Check if this quaternion represents an identity matrix, for rotation.
+ * Check if this quaternion represents an identity matrix for rotation,
+ * , ie (0,0,0,1).
*
* @return true if it is an identity rep., false otherwise
*/
@@ -403,7 +391,7 @@ public class Quaternion {
* @return true if representing a rotational matrix, false otherwise
*/
public boolean isRotationMatrix(float[] m) {
- final double epsilon = 0.01; // margin to allow for rounding errors
+ final float epsilon = 0.01f; // margin to allow for rounding errors
if (FloatUtil.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon)
return false;
if (FloatUtil.abs(m[0] * m[2] + m[3] * m[5] + m[6] * m[8]) > epsilon)
@@ -421,6 +409,6 @@ public class Quaternion {
private float determinant(float[] m) {
return m[0] * m[4] * m[8] + m[3] * m[7] * m[2] + m[6] * m[1] * m[5]
- - m[0] * m[7] * m[5] - m[3] * m[1] * m[8] - m[6] * m[4] * m[2];
+ - m[0] * m[7] * m[5] - m[3] * m[1] * m[8] - m[6] * m[4] * m[2];
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
index b0fc7f332..2bd45e3e4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
@@ -189,9 +189,9 @@ public class GLPixelBuffer {
private boolean disposed = false;
- public StringBuffer toString(StringBuffer sb) {
+ public StringBuilder toString(StringBuilder sb) {
if(null == sb) {
- sb = new StringBuffer();
+ 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("]");
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index 27ce7d8ec..dc96cb5f2 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -48,9 +48,16 @@ import com.jogamp.opengl.util.glsl.ShaderState;
* </p>
*/
public class ImmModeSink {
- 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);
+ protected static final boolean DEBUG_BEGIN_END;
+ protected static final boolean DEBUG_DRAW;
+ protected static final boolean DEBUG_BUFFER;
+
+ static {
+ Debug.initSingleton();
+ DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true);
+ DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true);
+ 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;
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 aceb609a1..df1bbdf26 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
@@ -109,7 +109,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
super.dispose();
}
- public StringBuffer toString(StringBuffer sb) {
+ 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("]");
return sb;
@@ -225,4 +225,4 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
}
}
}
-} \ No newline at end of file
+}
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 1735fcddd..c67141525 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
@@ -128,7 +128,12 @@ import jogamp.opengl.Debug;
@author Kenneth Russell
*/
public class TextRenderer {
- private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true);
+ private static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true);
+ }
// These are occasionally useful for more in-depth debugging
private static final boolean DISABLE_GLYPH_CACHE = false;
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 968391976..8e7781f07 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -55,8 +55,13 @@ import com.jogamp.opengl.util.GLArrayDataEditable;
* and can be retrieved via {@link #getShaderState(GL)}.
* </p>
*/
-public class ShaderState {
- public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true);
+public class ShaderState {
+ public static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true);
+ }
public ShaderState() {
}
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 7d110659a..d18fd4bae 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -221,7 +221,7 @@ public class ShaderUtil {
/** Returns true if GeometryShader is supported, i.e. whether GLContext is &ge; 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 ||
+ return ctx.getGLVersionNumber().compareTo(GLContext.Version320) >= 0 ||
ctx.isExtensionAvailable(GLExtensions.ARB_geometry_shader4);
}
@@ -249,10 +249,10 @@ public class ShaderUtil {
for(int i = source.length - 1; i>=0; i--) {
final CharSequence csq = source[i];
if(csq instanceof String) {
- // if ShaderCode.create(.. mutableStringBuffer == false )
+ // if ShaderCode.create(.. mutableStringBuilder == false )
tmp[i] = (String) csq;
} else {
- // if ShaderCode.create(.. mutableStringBuffer == true )
+ // if ShaderCode.create(.. mutableStringBuilder == true )
tmp[i] = source[i].toString();
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
index bf85bea87..f2ef3ac25 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -52,18 +52,32 @@ import com.jogamp.opengl.util.texture.spi.*;
* Represents an OpenGL texture object. Contains convenience routines
* for enabling/disabling OpenGL texture state, binding this texture,
* and computing texture coordinates for both the entire image as well
- * as a sub-image.
+ * as a sub-image.
+ *
+ * <a name="textureCallOrder"><h5>Order of Texture Commands</h5></a>
+ * <p>
+ * Due to many confusions w/ texture usage, following list described the order
+ * and semantics of texture unit selection, binding and enabling.
+ * <ul>
+ * <li><i>Optional:</i> Set active textureUnit via <code>gl.glActiveTexture(GL.GL_TEXTURE0 + textureUnit)</code>, <code>0</code> is default.</li>
+ * <li>Bind <code>textureId</code> -> active <code>textureUnit</code>'s <code>textureTarget</code> via <code>gl.glBindTexture(textureTarget, textureId)</code></li>
+ * <li><i>Compatible Context Only:</i> Enable active <code>textureUnit</code>'s <code>textureTarget</code> via <code>glEnable(textureTarget)</code>.
+ * <li><i>Optional:</i> Fiddle with the texture parameters and/or environment settings.</li>
+ * <li>GLSL: Use <code>textureUnit</code> in your shader program, enable shader program.</li>
+ * <li>Issue draw commands</li>
+ * </ul>
+ * </p>
*
* <p><a name="nonpow2"><b>Non-power-of-two restrictions</b></a>
* <br> When creating an OpenGL texture object, the Texture class will
- * attempt to leverage the <a
- * href="http://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt">GL_ARB_texture_non_power_of_two</a>
- * and <a
- * href="http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt">GL_ARB_texture_rectangle</a>
- * extensions (in that order) whenever possible. If neither extension
- * is available, the Texture class will simply upload a non-pow2-sized
+ * attempt to use <i>non-power-of-two textures</i> (NPOT) if available, see {@link GL#isNPOTTextureAvailable()}.
+ * Further more,
+ * <a href="http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt">GL_ARB_texture_rectangle</a>
+ * (RECT) will be attempted on OSX w/ ATI drivers.
+ * If NPOT is not available or RECT not chosen, the Texture class will simply upload a non-pow2-sized
* image into a standard pow2-sized texture (without any special
- * scaling). Since the choice of extension (or whether one is used at
+ * scaling).
+ * Since the choice of extension (or whether one is used at
* all) depends on the user's machine configuration, developers are
* recommended to use {@link #getImageTexCoords} and {@link
* #getSubImageTexCoords}, as those methods will calculate the
@@ -91,16 +105,24 @@ import com.jogamp.opengl.util.texture.spi.*;
* when switching between textures it is necessary to call {@link
* #bind}, but when drawing many triangles all using the same texture,
* for best performance only one call to {@link #bind} should be made.
+ * User may also utilize multiple texture units,
+ * see <a href="#textureCallOrder"> order of texture commands above</a>.
*
* <p><a name="premult"><b>Alpha premultiplication and blending</b></a>
- * <br> The mathematically correct way to perform blending in OpenGL
- * (with the SrcOver "source over destination" mode, or any other
- * Porter-Duff rule) is to use "premultiplied color components", which
- * means the R/G/ B color components have already been multiplied by
- * the alpha value. To make things easier for developers, the Texture
- * class will automatically convert non-premultiplied image data into
- * premultiplied data when storing it into an OpenGL texture. As a
- * result, it is important to use the correct blending function; for
+ * <p>
+ * <i>Disclaimer: Consider performing alpha premultiplication in shader code, if really desired! Otherwise use RGBA.</i><br/>
+ * </p>
+ * <p>
+ * The Texture class does not convert RGBA image data into
+ * premultiplied data when storing it into an OpenGL texture.
+ * </p>
+ * <p>
+ * The mathematically correct way to perform blending in OpenGL
+ * with the SrcOver "source over destination" mode, or any other
+ * Porter-Duff rule, is to use <i>premultiplied color components</i>,
+ * which means the R/G/ B color components must have been multiplied by
+ * the alpha value. If using <i>premultiplied color components</i>
+ * it is important to use the correct blending function; for
* example, the SrcOver rule is expressed as:
<pre>
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
@@ -138,9 +160,7 @@ import com.jogamp.opengl.util.texture.spi.*;
<TR> <TD> AlphaXor <TD> GL_ONE_MINUS_DST_ALPHA <TD> GL_ONE_MINUS_SRC_ALPHA
</TABLE>
</CENTER>
- *
- * @author Chris Campbell
- * @author Kenneth Russell
+ * @author Chris Campbell, Kenneth Russell, et.al.
*/
public class Texture {
/** The GL target type. */
@@ -207,12 +227,13 @@ public class Texture {
* Enables this texture's target (e.g., GL_TEXTURE_2D) in the
* given GL context's state. This method is a shorthand equivalent
* of the following OpenGL code:
- <pre>
- gl.glEnable(texture.getTarget());
- </pre>
- *
+ * <pre>
+ * gl.glEnable(texture.getTarget());
+ * </pre>
* <p>
- * Call is ignored if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}.
+ * Call is ignored if the {@link GL} object's context
+ * is using a core profile, see {@link GL#isGLcore()},
+ * or if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}.
* </p>
* <p>
* See the <a href="#perftips">performance tips</a> above for hints
@@ -224,7 +245,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void enable(GL gl) throws GLException {
- if(GLES2.GL_TEXTURE_EXTERNAL_OES != target) {
+ if( !gl.isGLcore() && GLES2.GL_TEXTURE_EXTERNAL_OES != target) {
gl.glEnable(target);
}
}
@@ -233,12 +254,13 @@ public class Texture {
* Disables this texture's target (e.g., GL_TEXTURE_2D) in the
* given GL state. This method is a shorthand equivalent
* of the following OpenGL code:
- <pre>
- gl.glDisable(texture.getTarget());
- </pre>
- *
+ * <pre>
+ * gl.glDisable(texture.getTarget());
+ * </pre>
* <p>
- * Call is ignored if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}.
+ * Call is ignored if the {@link GL} object's context
+ * is using a core profile, see {@link GL#isGLcore()},
+ * or if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}.
* </p>
* <p>
* See the <a href="#perftips">performance tips</a> above for hints
@@ -250,7 +272,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void disable(GL gl) throws GLException {
- if(GLES2.GL_TEXTURE_EXTERNAL_OES != target) {
+ if( !gl.isGLcore() && GLES2.GL_TEXTURE_EXTERNAL_OES != target ) {
gl.glDisable(target);
}
}
@@ -275,12 +297,6 @@ public class Texture {
}
/**
- * @deprecated use {@link #destroy(GL)}
- */
- public final void dispose(GL gl) throws GLException {
- destroy(gl);
- }
- /**
* Destroys the native resources used by this texture object.
*
* @throws GLException if any OpenGL-related errors occurred
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 6b41c0bc8..9f951d5da 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
@@ -75,7 +75,7 @@ import javax.media.opengl.GL;
// in case a fixed lookup function is being chosen, replace the name in our code
rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
- // Cache the TextureSequence shader details in StringBuffer:
+ // Cache the TextureSequence shader details in StringBuilder:
final StringBuilder sFpIns = new StringBuilder();
// .. declaration of the texture sampler using the implementation specific type
@@ -217,4 +217,4 @@ public interface TextureSequence {
* @throws IllegalStateException if instance is not initialized
*/
public String getTextureLookupFragmentShaderImpl() throws IllegalStateException ;
-} \ No newline at end of file
+}
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/jogl/classes/javax/media/opengl/DebugGL2.java b/src/jogl/classes/javax/media/opengl/DebugGL2.java
new file mode 100644
index 000000000..05bcf3d5e
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DebugGL2.java
@@ -0,0 +1,21 @@
+package javax.media.opengl;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class DebugGL2 extends DebugGL4bc {
+ public DebugGL2(GL2 downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3.java b/src/jogl/classes/javax/media/opengl/DebugGL3.java
new file mode 100644
index 000000000..c17f90667
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DebugGL3.java
@@ -0,0 +1,21 @@
+package javax.media.opengl;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class DebugGL3 extends DebugGL4bc {
+ public DebugGL3(GL3 downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3bc.java b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java
new file mode 100644
index 000000000..6e294d42b
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java
@@ -0,0 +1,21 @@
+package javax.media.opengl;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class DebugGL3bc extends DebugGL4bc {
+ public DebugGL3bc(GL3bc downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/DebugGL4.java b/src/jogl/classes/javax/media/opengl/DebugGL4.java
new file mode 100644
index 000000000..d21d39390
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DebugGL4.java
@@ -0,0 +1,21 @@
+package javax.media.opengl;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class DebugGL4 extends DebugGL4bc {
+ public DebugGL4(GL4 downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/DebugGLES2.java b/src/jogl/classes/javax/media/opengl/DebugGLES2.java
new file mode 100644
index 000000000..dee363c1b
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DebugGLES2.java
@@ -0,0 +1,21 @@
+package javax.media.opengl;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class DebugGLES2 extends DebugGLES3 {
+ public DebugGLES2(GLES2 downstream) {
+ super((GLES3)downstream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index b052769ca..b0f3da8e4 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -85,8 +85,13 @@ import jogamp.opengl.Debug;
*/
public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
- private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true);
+ private static final boolean DEBUG;
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true);
+ }
+
private final static int NO_SCORE = -9999999;
private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
private final static int OPAQUE_MISMATCH_PENALTY = 750;
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index 74c1b9609..f1853351f 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -88,35 +88,41 @@ public interface GLBase {
/**
* Indicates whether this GL object conforms to the OpenGL &ge; 4.0 compatibility profile.
* The GL4 compatibility profile includes the GL2, GL2ES1, GL2ES2, GL3, GL3bc and GL4 profile.
+ * @see GLContext#isGL4bc()
*/
public boolean isGL4bc();
/**
* Indicates whether this GL object conforms to the OpenGL &ge; 4.0 core profile.
* The GL4 core profile includes the GL2ES2, and GL3 profile.
+ * @see GLContext#isGL4()
*/
public boolean isGL4();
/**
* Indicates whether this GL object conforms to the OpenGL &ge; 3.1 compatibility profile.
* The GL3 compatibility profile includes the GL2, GL2ES1, GL2ES2 and GL3 profile.
+ * @see GLContext#isGL3bc()
*/
public boolean isGL3bc();
/**
* Indicates whether this GL object conforms to the OpenGL &ge; 3.1 core profile.
* The GL3 core profile includes the GL2ES2 profile.
+ * @see GLContext#isGL3()
*/
public boolean isGL3();
/**
* Indicates whether this GL object conforms to the OpenGL &le; 3.0 profile.
* The GL2 profile includes the GL2ES1 and GL2ES2 profile.
+ * @see GLContext#isGL2()
*/
public boolean isGL2();
/**
* Indicates whether this GL object conforms to the OpenGL ES1 &ge; 1.0 profile.
+ * @see GLContext#isGLES1()
*/
public boolean isGLES1();
@@ -127,103 +133,205 @@ public interface GLBase {
* To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}.
* </p>
* @see #isGLES2Compatible()
+ * @see GLContext#isGLES2()
*/
public boolean isGLES2();
/**
+ * Indicates whether this GL object conforms to the OpenGL ES2 &ge; 3.0 profile.
+ * <p>
+ * Remark: ES3 compatible desktop profiles are not included.
+ * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}.
+ * </p>
+ * @see #isGLES3Compatible()
+ * @see GLContext#isGLES3()
+ */
+ public boolean isGLES3();
+
+ /**
* Indicates whether this GL object conforms to one of the OpenGL ES profiles,
* see {@link #isGLES1()} and {@link #isGLES2()}.
+ * @see GLContext#isGLES()
*/
public boolean isGLES();
/**
* Indicates whether this GL object conforms to a GL2ES1 compatible profile.
+ * @see GLContext#isGL2ES1()
*/
public boolean isGL2ES1();
/**
* Indicates whether this GL object conforms to a GL2ES2 compatible profile.
+ * @see GLContext#isGL2ES2()
*/
public boolean isGL2ES2();
/**
+ * Indicates whether this GL object conforms to a GL3ES3 compatible profile.
+ * @see GLContext#isGL3ES3()
+ */
+ public boolean isGL3ES3();
+
+ /**
+ * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true.
+ * <p>Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]</p>
+ * @see GLContext#isGL4ES3()
+ */
+ public boolean isGL4ES3();
+
+ /**
+ * Indicates whether this GL object conforms to a GL2GL3 compatible profile.
+ * @see GLContext#isGL2GL3()
+ */
+ public boolean isGL2GL3();
+
+ /**
+ * Indicates whether this GL object uses a GL4 core profile. <p>Includes [ GL4 ].</p>
+ * @see GLContext#isGL4core()
+ */
+ public boolean isGL4core();
+
+ /**
+ * Indicates whether this GL object uses a GL3 core profile. <p>Includes [ GL4, GL3 ].</p>
+ * @see GLContext#isGL3core()
+ */
+ public boolean isGL3core();
+
+ /**
+ * Indicates whether this GL object uses a GL core profile. <p>Includes [ GL4, GL3, GLES3, GL2ES2 ].</p>
+ * @see GLContext#isGLcore()
+ */
+ public boolean isGLcore();
+
+ /**
* Indicates whether this GL object is compatible with the core OpenGL ES2 functionality.
* @return true if this context is an ES2 context or implements
- * the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false
+ * the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false
+ * @see GLContext#isGLES2Compatible()
*/
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.
+ * <p>
+ * Return true if the underlying context is an ES3 context or implements
+ * the extension <code>GL_ARB_ES3_compatibility</code>, otherwise false.
+ * </p>
+ * <p>
+ * Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * </p>
+ * @see GLContext#isGLES3Compatible()
*/
- public boolean isGL2GL3();
+ public boolean isGLES3Compatible();
- /** Indicates whether this GL object supports GLSL. */
+ /**
+ * Indicates whether this GL object supports GLSL.
+ * @see GLContext#hasGLSL()
+ */
public boolean hasGLSL();
/**
+ * Returns the downstream GL instance in case this is a wrapping pipeline, otherwise <code>null</code>.
+ * <p>
+ * See {@link #getRootGL()} for retrieving the implementing root instance.
+ * </p>
+ * @throws GLException if the downstream instance is not null and not a GL implementation
+ * @see #getRootGL()
+ */
+ public GL getDownstreamGL() throws GLException;
+
+ /**
+ * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}.
+ * <p>
+ * If this instance is not a wrapping pipeline, i.e. has no downstream instance,
+ * this instance is returned.
+ * </p>
+ * @throws GLException if the root instance is not a GL implementation
+ */
+ public GL getRootGL() throws GLException;
+
+ /**
* Casts this object to the GL interface.
- * @throws GLException if this GLObject is not a GL implementation
+ * @throws GLException if this object is not a GL implementation
*/
public GL getGL() throws GLException;
/**
* Casts this object to the GL4bc interface.
- * @throws GLException if this GLObject is not a GL4bc implementation
+ * @throws GLException if this object is not a GL4bc implementation
*/
public GL4bc getGL4bc() throws GLException;
/**
* Casts this object to the GL4 interface.
- * @throws GLException if this GLObject is not a GL4 implementation
+ * @throws GLException if this object is not a GL4 implementation
*/
public GL4 getGL4() throws GLException;
/**
* Casts this object to the GL3bc interface.
- * @throws GLException if this GLObject is not a GL3bc implementation
+ * @throws GLException if this object is not a GL3bc implementation
*/
public GL3bc getGL3bc() throws GLException;
/**
* Casts this object to the GL3 interface.
- * @throws GLException if this GLObject is not a GL3 implementation
+ * @throws GLException if this object is not a GL3 implementation
*/
public GL3 getGL3() throws GLException;
/**
* Casts this object to the GL2 interface.
- * @throws GLException if this GLObject is not a GL2 implementation
+ * @throws GLException if this object is not a GL2 implementation
*/
public GL2 getGL2() throws GLException;
/**
* Casts this object to the GLES1 interface.
- * @throws GLException if this GLObject is not a GLES1 implementation
+ * @throws GLException if this object is not a GLES1 implementation
*/
public GLES1 getGLES1() throws GLException;
/**
* Casts this object to the GLES2 interface.
- * @throws GLException if this GLObject is not a GLES2 implementation
+ * @throws GLException if this object is not a GLES2 implementation
*/
public GLES2 getGLES2() throws GLException;
/**
+ * Casts this object to the GLES3 interface.
+ * @throws GLException if this object 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
+ * @throws GLException if this object is not a GL2ES1 implementation
*/
public GL2ES1 getGL2ES1() throws GLException;
/**
* Casts this object to the GL2ES2 interface.
- * @throws GLException if this GLObject is not a GL2ES2 implementation
+ * @throws GLException if this object is not a GL2ES2 implementation
*/
public GL2ES2 getGL2ES2() throws GLException;
/**
+ * Casts this object to the GL3ES3 interface.
+ * @throws GLException if this object is not a GL3ES3 implementation
+ */
+ public GL3ES3 getGL3ES3() throws GLException;
+
+ /**
+ * Casts this object to the GL4ES3 interface.
+ * @throws GLException if this object is not a GL4ES3 implementation
+ */
+ public GL4ES3 getGL4ES3() throws GLException;
+
+ /**
* Casts this object to the GL2GL3 interface.
- * @throws GLException if this GLObject is not a GL2GL3 implementation
+ * @throws GLException if this object is not a GL2GL3 implementation
*/
public GL2GL3 getGL2GL3() throws GLException;
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index cc37da0ff..aa5fca2c2 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -73,6 +73,10 @@ import com.jogamp.opengl.GLRendererQuirks;
refer to a given context. */
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;
+
/**
* If <code>true</code> (default), bootstrapping the available GL profiles
* will use the highest compatible GL context for each profile,
@@ -102,10 +106,6 @@ public abstract class GLContext {
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);
- 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);
/** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
@@ -131,17 +131,30 @@ public abstract class GLContext {
/* 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);
+ /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. */
+ public static final VersionNumber Version300 = new VersionNumber(3, 0, 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);
+ public static final VersionNumber Version310 = new VersionNumber(3, 1, 0);
+
+ /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */
+ public static final VersionNumber Version320 = new VersionNumber(3, 2, 0);
- /** Version 3.0. As an OpenGL version, it qualifies for {@link #isGL2()} only */
- public static final VersionNumber Version30 = new VersionNumber(3, 0, 0);
+ /** Version 4.3. As an OpenGL version, it qualifies for <code>GL_ARB_ES3_compatibility</code> */
+ public static final VersionNumber Version430 = new VersionNumber(4, 3, 0);
- protected static final VersionNumber Version80 = new VersionNumber(8, 0, 0);
+ protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0);
+ //
+ // Cached keys, bits [0..15]
+ //
+
+ /** Context option bits, full bit mask covering bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */
+ protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
+
+ /** Context option bits, cached bit mask covering 9 bits [0..8], i.e. <code>0x000001FF</code>, {@value}. Leaving 7 bits for non cached options, i.e. 9:7. */
+ protected static final int CTX_IMPL_CACHE_MASK = 0x000001FF;
+
/** <code>ARB_create_context</code> related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
protected static final int CTX_IS_ARB_CREATED = 1 << 0;
/** <code>ARB_create_context</code> related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
@@ -154,20 +167,36 @@ public abstract class GLContext {
protected static final int CTX_OPTION_FORWARD = 1 << 4;
/** <code>ARB_create_context</code> 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 [9..15]
+ //
+
/** <code>GL_ARB_ES2_compatibility</code> 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 << 9;
- /** Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
+ /** <code>GL_ARB_ES3_compatibility</code> 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 << 10;
+
+ /**
+ * 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 << 11;
+ /**
+ * Context supports <code>OES_single_precision</code>, 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 << 12;
+
private static final ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>();
private final HashMap<String, Object> attachedObjects = new HashMap<String, Object>();
@@ -481,6 +510,17 @@ public abstract class GLContext {
public abstract void destroy();
/**
+ * Returns the implementing root GL instance of this GLContext's GL object,
+ * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}.
+ * @throws GLException if the root instance is not a GL implementation
+ * @see GLBase#getRootGL()
+ * @see GLBase#getDownstreamGL()
+ * @see #getGL()
+ * @see #setGL(GL)
+ */
+ public abstract GL getRootGL();
+
+ /**
* Returns the GL pipeline object for this GLContext.
*
* @return the aggregated GL instance, or null if this context was not yet made current.
@@ -671,10 +711,6 @@ public abstract class GLContext {
return ctxVersionString;
}
- /** @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()
@@ -753,7 +789,7 @@ public abstract class GLContext {
return "";
}
final int minor = ctxGLSLVersion.getMinor();
- final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version30) >= 0 ? " es" : "";
+ final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : "";
return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ;
}
@@ -782,10 +818,21 @@ public abstract class GLContext {
/**
* @return true if this context is an ES2 context or implements
- * the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false
+ * the extension <code>GL_ARB_ES3_compatibility</code> or <code>GL_ARB_ES2_compatibility</code>, 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 <code>GL_ARB_ES3_compatibility</code>, otherwise false.
+ * <p>
+ * Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * </p>
+ */
+ public final boolean isGLES3Compatible() {
+ return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ;
}
/**
@@ -824,6 +871,15 @@ public abstract class GLContext {
}
/**
+ * Returns <code>true</code> if <code>OES_single_precision</code>, fp32, fixed function point (FFP) compatibility entry points available,
+ * otherwise <code>false</code>.
+ * @see #CTX_IMPL_FP32_COMPAT_API
+ */
+ public final boolean hasFP32CompatAPI() {
+ return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ;
+ }
+
+ /**
* Returns <code>true</code> if full FBO support is available, otherwise <code>false</code>.
* <p>
* Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions
@@ -879,78 +935,198 @@ public abstract class GLContext {
isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ;
}
- /** @see GLProfile#isGL4bc() */
+ /**
+ * Indicates whether this GLContext is capable of GL4bc. <p>Includes [ GL4bc ].</p>
+ * @see GLProfile#isGL4bc()
+ */
public final boolean isGL4bc() {
- return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED)
- && 0 != (ctxOptions & CTX_PROFILE_COMPAT);
+ return 0 != (ctxOptions & CTX_IS_ARB_CREATED) &&
+ 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
+ ctxVersion.getMajor() >= 4;
}
- /** @see GLProfile#isGL4() */
+ /**
+ * Indicates whether this GLContext is capable of GL4. <p>Includes [ GL4bc, GL4 ].</p>
+ * @see GLProfile#isGL4()
+ */
public final boolean isGL4() {
- return ctxVersion.getMajor() >= 4 && 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.getMajor() >= 4;
}
- /** Indicates whether this profile is capable of GL4 (core only). <p>Includes [ GL4 ].</p> */
+ /**
+ * Indicates whether this GLContext uses a GL4 core profile. <p>Includes [ GL4 ].</p>
+ */
public final boolean isGL4core() {
- return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED)
- && 0 != (ctxOptions & CTX_PROFILE_CORE);
+ return 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
+ 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.getMajor() >= 4;
}
- /** @see GLProfile#isGL3bc() */
+ /**
+ * Indicates whether this GLContext is capable of GL3bc. <p>Includes [ GL4bc, GL3bc ].</p>
+ * @see GLProfile#isGL3bc()
+ */
public final boolean isGL3bc() {
- return ctxVersion.compareTo(Version31) >= 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() */
+ /**
+ * Indicates whether this GLContext is capable of GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3 ].</p>
+ * @see GLProfile#isGL3()
+ */
public final boolean isGL3() {
- return ctxVersion.compareTo(Version31) >= 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 <p>Includes [ GL4, GL3 ].</p> */
+ /**
+ * Indicates whether this GLContext uses a GL3 core profile. <p>Includes [ GL4, GL3 ].</p>
+ */
public final boolean isGL3core() {
- return ctxVersion.compareTo(Version31) >= 0
- && 0 != (ctxOptions & CTX_IS_ARB_CREATED)
- && 0 != (ctxOptions & CTX_PROFILE_CORE);
+ return 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
+ 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.compareTo(Version310) >= 0;
+ }
+
+ /**
+ * Indicates whether this GLContext uses a GL core profile. <p>Includes [ GL4, GL3, GLES3, GL2ES2 ].</p>
+ */
+ public final boolean isGLcore() {
+ return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ) ||
+ ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
+ 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.compareTo(Version310) >= 0
+ ) ;
}
- /** @see GLProfile#isGL2() */
+ /**
+ * Indicates whether this GLContext's native profile does not implement a default <i>vertex array object</i> (VAO),
+ * starting w/ OpenGL 3.1 core and GLES3.
+ * <p>Includes [ GL4, GL3, GLES3 ].</p>
+ * <pre>
+ 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).
+ * </pre>
+ * <pre>
+ GLES3 is included, since upcoming ES releases &gt; 3.0 may behave the same:
+ GL ES 3.0 spec F.1. Legacy Features (p 322).
+ * </pre>
+ * <p>
+ * If no default VAO is implemented in the native OpenGL profile,
+ * an own default VAO is being used, see {@link #getDefaultVAO()}.
+ * </p>
+ * @see #getDefaultVAO()
+ */
+ public final boolean hasNoDefaultVAO() {
+ return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) ||
+ ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
+ 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.compareTo(Version310) >= 0
+ ) ;
+ }
+
+ /**
+ * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()},
+ * an <i>own default VAO</i> will be created and bound at context creation.
+ * <p>
+ * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()}
+ * returns <code>false</code>, this method returns <code>0</code>.
+ * </p>
+ * <p>
+ * Otherwise this method returns the VAO object name
+ * representing this GLContext's <i>own default VAO</i>.
+ * </p>
+ * @see #hasNoDefaultVAO()
+ */
+ public abstract int getDefaultVAO();
+
+ /**
+ * Indicates whether this GLContext is capable of GL2. <p>Includes [ GL4bc, GL3bc, GL2 ].</p>
+ * @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() */
+ /**
+ * Indicates whether this GLContext is capable of GL2GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].</p>
+ * @see GLProfile#isGL2GL3()
+ */
public final boolean isGL2GL3() {
return isGL2() || isGL3();
}
- /** @see GLProfile#isGLES1() */
+ /**
+ * Indicates whether this GLContext is capable of GLES1. <p>Includes [ GLES1 ].</p>
+ * @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() */
+ /**
+ * Indicates whether this GLContext is capable of GLES2. <p>Includes [ GLES3, GLES2 ].</p>
+ * @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 ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GLES3. <p>Includes [ GLES3 ].</p>
+ * @see GLProfile#isGLES3()
+ */
+ public final boolean isGLES3() {
+ return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ;
}
- /** @see GLProfile#isGLES() */
+ /**
+ * Indicates whether this GLContext is capable of GLES. <p>Includes [ GLES3, GLES1, GLES2 ].</p>
+ * @see GLProfile#isGLES()
+ */
public final boolean isGLES() {
return 0 != ( CTX_PROFILE_ES & ctxOptions ) ;
}
- /** @see GLProfile#isGL2ES1() */
+ /**
+ * Indicates whether this GLContext is capable of GL2ES1. <p>Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].</p>
+ * @see GLProfile#isGL2ES1()
+ */
public final boolean isGL2ES1() {
- return isGL2() || isGLES1() ;
+ return isGLES1() || isGL2();
}
- /** @see GLProfile#isGL2ES2() */
+ /**
+ * Indicates whether this GLContext is capable of GL2ES2. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].</p>
+ * @see GLProfile#isGL2ES2()
+ */
public final boolean isGL2ES2() {
- return isGL2GL3() || isGLES2() ;
+ return isGLES2() || isGL2GL3();
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL3ES3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].</p>
+ * @see GLProfile#isGL3ES3()
+ */
+ public final boolean isGL3ES3() {
+ return isGL4ES3() || isGL3();
+ }
+
+ /**
+ * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true.
+ * <p>Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]</p>
+ * @see GLProfile#isGL4ES3()
+ */
+ public final boolean isGL4ES3() {
+ return isGLES3Compatible() ;
}
/**
@@ -1161,38 +1337,73 @@ public abstract class GLContext {
/* 1.*/ { 0, 1, 2, 3, 4, 5 },
/* 2.*/ { 0, 1 },
/* 3.*/ { 0, 1, 2, 3 },
- /* 4.*/ { 0, 1, 2 } };
+ /* 4.*/ { 0, 1, 2, 3 } };
+
+ public static final int ES_VERSIONS[][] = {
+ /* 0.*/ { -1 },
+ /* 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.length) return false;
- if(0>minor || minor>=GL_VERSIONS[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;
@@ -1296,9 +1507,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<String> keys = deviceVersionAvailable.keySet();
@@ -1394,9 +1605,9 @@ public abstract class GLContext {
*/
protected static final void getRequestMajorAndCompat(final GLProfile glp, int[/*2*/] reqMajorCTP) {
final GLProfile glpImpl = glp.getImpl();
- if(glpImpl.isGL4()) {
+ if( glpImpl.isGL4() ) {
reqMajorCTP[0]=4;
- } else if (glpImpl.isGL3()) {
+ } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) {
reqMajorCTP[0]=3;
} else if (glpImpl.isGLES1()) {
reqMajorCTP[0]=1;
@@ -1521,6 +1732,34 @@ 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);
+ }
+
+ /**
+ * Returns true if a ES3 compatible profile is available,
+ * i.e. either a &ge; 4.3 context or a &ge; 3.1 context supporting <code>GL_ARB_ES3_compatibility</code>,
+ * otherwise false.
+ * <p>
+ * Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * </p>
+ */
+ public static final boolean isGLES3CompatibleAvailable(AbstractGraphicsDevice device) {
+ int major[] = { 0 };
+ int minor[] = { 0 };
+ int ctp[] = { 0 };
+ boolean ok;
+
+ ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp);
+ if( !ok ) {
+ ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp);
+ }
+ if( !ok ) {
+ ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp);
+ }
+ return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT );
+ }
+
public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) {
return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware);
}
@@ -1549,13 +1788,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/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 {
* </p>
* <p>
* 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.
* </p>
* <p>
* 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 {
* </p>
* <p>
* 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.
* </p>
* <p>
* If neither FBO nor Pbuffer is available,
@@ -520,7 +520,7 @@ public abstract class GLDrawableFactory {
* </p>
* <p>
* 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.
* </p>
* <p>
* 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 <i>pbuffer surface</i>.
+ * <p>
+ * Some older graphics cards do not have this capability,
+ * as well as some new GL implementation, i.e. OpenGL 3 core on OSX.
+ * </p>
*
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> 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/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
index 2bfc77d4a..c6bf26235 100644
--- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
@@ -51,8 +51,23 @@ public class GLPipelineFactory {
/**
* Creates a pipelined GL instance using the given downstream <code>downstream</code>
- * and optional arguments <code>additionalArgs</code> for the constructor.<br>
+ * and optional arguments <code>additionalArgs</code> for the constructor.
*
+ * <p>
+ * Sample code which installs a Debug and Trace pipeline
+ * automatic w/ user defined interface, here: GL2ES2:
+ * <pre>
+ * gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, gl, null) );
+ * gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, gl, new Object[] { System.err } ) );
+ * </pre>
+ * or automatic w/ automatic defined class:
+ * <pre>
+ * gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) );
+ * gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) );
+ * </pre>
+ * </p>
+ *
+ * <p>
* The upstream GL instance is determined as follows:
* <ul>
* <li> Use <code>pipelineClazzBaseName</code> as the class name's full basename, incl. package name</li>
@@ -65,7 +80,8 @@ public class GLPipelineFactory {
* <li> If upstream class is available use it, end loop.</li>
* </ul>
* </ul>
- * </ul><br>
+ * </ul>
+ * </p>
*
* @param pipelineClazzBaseName the basename of the pipline class name
* @param reqInterface optional requested interface to be used, may be null, in which case the first matching one is used
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 1b6af22d4..51b822449 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));
}
}
@@ -299,6 +299,17 @@ public class GLProfile {
}
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 {
sb.append(", GL3bc ");
@@ -332,11 +343,15 @@ public class GLProfile {
}
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent);
} else {
- sb.append(", GL2ES1 ");
+ sb.append(", GLES2 ");
+ }
+ avail=isAvailableImpl(map, GLES2);
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES);
}
- sb.append(isAvailableImpl(map, GL2ES1));
if(useIndent) {
doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent);
@@ -350,6 +365,13 @@ public class GLProfile {
}
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("GL2ES2").append(indent);
} else {
sb.append(", GL2ES2 ");
@@ -357,15 +379,11 @@ public class GLProfile {
sb.append(isAvailableImpl(map, GL2ES2));
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent);
} else {
- sb.append(", GLES2 ");
- }
- avail=isAvailableImpl(map, GLES2);
- sb.append(avail);
- if(avail) {
- glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES);
+ sb.append(", GL2ES1 ");
}
+ sb.append(isAvailableImpl(map, GL2ES1));
if(useIndent) {
indentCount--;
@@ -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 {
* <p> This includes the generic subset profiles GL2GL3, GL2ES2 and GL2ES1.</p>
*
* <ul>
- * <li> GL4bc
- * <li> GL3bc
- * <li> GL2
- * <li> GL4
- * <li> GL3
- * <li> GL2GL3
- * <li> GLES2
- * <li> GL2ES2
- * <li> GLES1
- * <li> GL2ES1
+ * <li> GL4bc </li>
+ * <li> GL3bc </li>
+ * <li> GL2 </li>
+ * <li> GL4 </li>
+ * <li> GL3 </li>
+ * <li> GLES3 </li>
+ * <li> GL4ES3 </li>
+ * <li> GL2GL3 </li>
+ * <li> GLES2 </li>
+ * <li> GL2ES2 </li>
+ * <li> GLES1 </li>
+ * <li> GL2ES1 </li>
* </ul>
*
*/
- 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.
*
* <ul>
- * <li> GL4bc
- * <li> GL4
- * <li> GL3bc
- * <li> GL3
- * <li> GL2
- * <li> GLES2
- * <li> GLES1
+ * <li> GL4bc </li>
+ * <li> GL4 </li>
+ * <li> GL3bc </li>
+ * <li> GL3 </li>
+ * <li> GLES3 </li>
+ * <li> GL2 </li>
+ * <li> GLES2 </li>
+ * <li> GLES1 </li>
* </ul>
*
*/
- 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.
*
* <ul>
- * <li> GLES1
- * <li> GLES2
- * <li> GL2
- * <li> GL3
- * <li> GL3bc
- * <li> GL4
- * <li> GL4bc
+ * <li> GLES1 </li>
+ * <li> GLES2 </li>
+ * <li> GL2 </li>
+ * <li> GLES3 </li>
+ * <li> GL3 </li>
+ * <li> GL3bc </li>
+ * <li> GL4 </li>
+ * <li> GL4bc </li>
* </ul>
*
*/
- 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.
*
* <ul>
- * <li> GL2
- * <li> GL3bc
- * <li> GL4bc
- * <li> GL3
- * <li> GL4
+ * <li> GL2 </li>
+ * <li> GL3bc </li>
+ * <li> GL4bc </li>
+ * <li> GL3 </li>
+ * <li> GL4 </li>
* </ul>
*
*/
@@ -521,10 +549,10 @@ public class GLProfile {
* Order of maximum fixed function profiles
*
* <ul>
- * <li> GL4bc
- * <li> GL3bc
- * <li> GL2
- * <li> GLES1
+ * <li> GL4bc </li>
+ * <li> GL3bc </li>
+ * <li> GL2 </li>
+ * <li> GLES1 </li>
* </ul>
*
*/
@@ -534,28 +562,30 @@ public class GLProfile {
* Order of maximum programmable shader profiles
*
* <ul>
- * <li> GL4bc
- * <li> GL4
- * <li> GL3bc
- * <li> GL3
- * <li> GL2
- * <li> GLES2
+ * <li> GL4bc </li>
+ * <li> GL4 </li>
+ * <li> GL3bc </li>
+ * <li> GL3 </li>
+ * <li> GLES3 </li>
+ * <li> GL2 </li>
+ * <li> GLES2 </li>
* </ul>
*
*/
- 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 <i>core only</i> profiles
*
* <ul>
- * <li> GL4
- * <li> GL3
- * <li> GLES2
+ * <li> GL4 </li>
+ * <li> GL3 </li>
+ * <li> GLES3 </li>
+ * <li> GLES2 </li>
* </ul>
*
*/
- 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}
@@ -755,6 +785,36 @@ public class GLProfile {
}
/**
+ * Returns the GL4ES3 profile implementation, hence compatible w/ GL4ES3.<br/>
+ * It returns:
+ * <pre>
+ * GLProfile.get(device, GLProfile.GL4ES3).getImpl());
+ * </pre>
+ * <p>Selection favors hardware rasterizer.</p>
+ *
+ * @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.
+ * <p>Selection favors hardware rasterizer.</p>
+ * @see #getGL4ES3(AbstractGraphicsDevice)
+ */
+ public static GLProfile getGL4ES3()
+ throws GLException
+ {
+ return get(defaultDevice, GL4ES3).getImpl();
+ }
+
+ /**
* Returns the GL2GL3 profile implementation, hence compatible w/ GL2GL3.<br/>
* It returns:
* <pre>
@@ -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 ||
@@ -1025,7 +1092,7 @@ public class GLProfile {
return isGL4() || isGL3bc() || GL3 == profile;
}
- /** Indicates whether this context is a GL2 context <p>Includes [ GL4bc, GL3bc, GL2 ].</p> */
+ /** Indicates whether this profile is capable of GL2 . <p>Includes [ GL4bc, GL3bc, GL2 ].</p> */
public final boolean isGL2() {
return isGL3bc() || GL2 == profile;
}
@@ -1035,14 +1102,19 @@ public class GLProfile {
return GLES1 == profile;
}
- /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES2 ].</p> */
+ /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES3, GLES2 ].</p> */
public final boolean isGLES2() {
- return GLES2 == profile;
+ return GLES3 == profile || GLES2 == profile;
+ }
+
+ /** Indicates whether this profile is capable of GLES3. <p>Includes [ GLES3 ].</p> */
+ public final boolean isGLES3() {
+ return GLES3 == profile;
}
- /** Indicates whether this profile is capable of GLES. <p>Includes [ GLES1, GLES2 ].</p> */
+ /** Indicates whether this profile is capable of GLES. <p>Includes [ GLES3, GLES1, GLES2 ].</p> */
public final boolean isGLES() {
- return GLES2 == profile || GLES1 == profile;
+ return GLES3 == profile || GLES2 == profile || GLES1 == profile;
}
/** Indicates whether this profile is capable of GL2ES1. <p>Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].</p> */
@@ -1050,17 +1122,27 @@ public class GLProfile {
return GL2ES1 == profile || isGLES1() || isGL2();
}
- /** Indicates whether this profile is capable os GL2GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].</p> */
+ /** Indicates whether this profile is capable of GL2GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].</p> */
public final boolean isGL2GL3() {
return GL2GL3 == profile || isGL3() || isGL2();
}
-
- /** Indicates whether this profile is capable os GL2ES2. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL2ES2, GLES2 ].</p> */
+
+ /** Indicates whether this profile is capable of GL2ES2. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].</p> */
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. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].</p> */
+ public final boolean isGL3ES3() {
+ return isGL4ES3() || isGL3();
+ }
+
+ /** Indicates whether this profile is capable of GL4ES3. <p>Includes [ GL4bc, GL4, GLES3 ].</p> */
+ 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<String, GLProfile> _mappedProfiles = new HashMap<String, GLProfile>(GL_PROFILE_LIST_ALL.length + 1 /* default */);
+ final HashMap<String, GLProfile> _mappedProfiles = new HashMap<String, GLProfile>(GL_PROFILE_LIST_ALL.length + 1 /* default */);
for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) {
- String profile = GL_PROFILE_LIST_ALL[i];
- String profileImpl = computeProfileImpl(device, profile, desktopCtxUndef, esCtxUndef, isHardwareRasterizer);
- if(null!=profileImpl) {
+ final String profile = GL_PROFILE_LIST_ALL[i];
+ final String profileImpl = computeProfileImpl(device, profile, desktopCtxUndef, esCtxUndef, isHardwareRasterizer);
+ if( null != profileImpl ) {
final GLProfile glProfile;
- if(profile.equals(profileImpl)) {
+ if( profile.equals( profileImpl ) ) {
glProfile = new GLProfile(profile, null, isHardwareRasterizer[0]);
} else {
- final GLProfile _mglp = _mappedProfiles.get(profileImpl);
- if(null == _mglp) {
- throw new InternalError("XXX0");
+ final GLProfile _mglp = _mappedProfiles.get( profileImpl );
+ if( null == _mglp ) {
+ throw new InternalError("XXX0 profile["+i+"]: "+profile+" -> 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);
@@ -1774,10 +1861,6 @@ public class GLProfile {
* Returns the profile implementation
*/
private static String computeProfileImpl(AbstractGraphicsDevice device, String profile, boolean desktopCtxUndef, boolean esCtxUndef, boolean isHardwareRasterizer[]) {
- // OSX GL3.. doesn't support GLSL<150,
- // hence GL2ES2 and GL2GL3 need to be mapped on GL2 on OSX for GLSL compatibility.
- final boolean isOSX = Platform.OS_TYPE == Platform.OSType.MACOS;
-
if (GL2ES1.equals(profile)) {
final boolean es1HardwareRasterizer[] = new boolean[1];
final boolean gles1Available = hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, es1HardwareRasterizer) );
@@ -1805,29 +1888,27 @@ 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.isGL4Available(device, isHardwareRasterizer)) {
- if(!gles2HWAvailable || isHardwareRasterizer[0]) {
- return GL4;
- }
+ }
+ if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
+ if(!gles2HWAvailable || isHardwareRasterizer[0]) {
+ return GL4bc;
}
- if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
- if(!gles2HWAvailable || isHardwareRasterizer[0]) {
- return GL3bc;
- }
+ }
+ if(GLContext.isGL3Available(device, isHardwareRasterizer)) {
+ if(!gles2HWAvailable || isHardwareRasterizer[0]) {
+ return GL3;
}
- if(GLContext.isGL3Available(device, isHardwareRasterizer)) {
- if(!gles2HWAvailable || isHardwareRasterizer[0]) {
- return GL3;
- }
+ }
+ if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
+ if(!gles2HWAvailable || isHardwareRasterizer[0]) {
+ return GL3bc;
}
}
if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) {
@@ -1840,15 +1921,48 @@ public class GLProfile {
isHardwareRasterizer[0] = es2HardwareRasterizer[0];
return GLES2;
}
+ } else if (GL4ES3.equals(profile)) {
+ final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device);
+ if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) {
+ 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(GLContext.isGL3Available(device, isHardwareRasterizer)) {
+ if(!gles3HWAvailable || isHardwareRasterizer[0]) {
+ return GL3;
+ }
+ }
+ if( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
+ if(!gles3HWAvailable || isHardwareRasterizer[0]) {
+ return GL3bc;
+ }
+ }
+ }
+ if(gles3Available) {
+ isHardwareRasterizer[0] = es3HardwareRasterizer[0];
+ return GLES3;
+ }
+ }
} else if(GL2GL3.equals(profile)) {
if(hasGL234Impl) {
- if(!isOSX && GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
+ if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
return GL4bc;
- } else if(!isOSX && GLContext.isGL4Available(device, isHardwareRasterizer)) {
+ } else if( GLContext.isGL4Available(device, isHardwareRasterizer)) {
return GL4;
- } else if(!isOSX && GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
+ } else if( GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
return GL3bc;
- } else if(!isOSX && GLContext.isGL3Available(device, isHardwareRasterizer)) {
+ } else if( GLContext.isGL3Available(device, isHardwareRasterizer)) {
return GL3;
} else if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) {
return GL2;
@@ -1864,7 +1978,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/javax/media/opengl/TraceGL2.java b/src/jogl/classes/javax/media/opengl/TraceGL2.java
new file mode 100644
index 000000000..58f5d9f99
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/TraceGL2.java
@@ -0,0 +1,23 @@
+package javax.media.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing tracing information to a user-specified {@link java.io.PrintStream}
+ * before and after each OpenGL method call.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class TraceGL2 extends TraceGL4bc {
+ public TraceGL2(GL2 downstream, PrintStream stream) {
+ super((GL4bc)downstream, stream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3.java b/src/jogl/classes/javax/media/opengl/TraceGL3.java
new file mode 100644
index 000000000..616b31f61
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/TraceGL3.java
@@ -0,0 +1,23 @@
+package javax.media.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing tracing information to a user-specified {@link java.io.PrintStream}
+ * before and after each OpenGL method call.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class TraceGL3 extends TraceGL4bc {
+ public TraceGL3(GL3 downstream, PrintStream stream) {
+ super((GL4bc)downstream, stream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3bc.java b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java
new file mode 100644
index 000000000..f3761d4d6
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java
@@ -0,0 +1,23 @@
+package javax.media.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing tracing information to a user-specified {@link java.io.PrintStream}
+ * before and after each OpenGL method call.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class TraceGL3bc extends TraceGL4bc {
+ public TraceGL3bc(GL3bc downstream, PrintStream stream) {
+ super((GL4bc)downstream, stream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/TraceGL4.java b/src/jogl/classes/javax/media/opengl/TraceGL4.java
new file mode 100644
index 000000000..a12bf0f47
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/TraceGL4.java
@@ -0,0 +1,23 @@
+package javax.media.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing tracing information to a user-specified {@link java.io.PrintStream}
+ * before and after each OpenGL method call.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class TraceGL4 extends TraceGL4bc {
+ public TraceGL4(GL4 downstream, PrintStream stream) {
+ super((GL4bc)downstream, stream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/TraceGLES2.java b/src/jogl/classes/javax/media/opengl/TraceGLES2.java
new file mode 100644
index 000000000..38d60e3ac
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/TraceGLES2.java
@@ -0,0 +1,23 @@
+package javax.media.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing tracing information to a user-specified {@link java.io.PrintStream}
+ * before and after each OpenGL method call.
+ * </p>
+ * <p>
+ * Sample code which installs this pipeline, manual:
+ * <pre>
+ * gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * </pre>
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ * </p>
+ */
+public class TraceGLES2 extends TraceGLES3 {
+ public TraceGLES2(GLES2 downstream, PrintStream stream) {
+ super((GLES3)downstream, stream);
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index b11f359be..2a23defbe 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -110,6 +110,7 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvide
<P>
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 <code>jogl.gljpanel.noglsl</code>.
+ See <a href="#fboGLSLVerticalFlip">details here</a>.
</P>
<P>
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(..)}
@@ -125,15 +126,21 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvide
on the prepared {@link BufferedImage} as described above.
</p>
<P>
- * Please read <A HREF="GLCanvas.html#java2dgl">Java2D OpenGL Remarks</A>.
+ * Please read <a href="GLCanvas.html#java2dgl">Java2D OpenGL Remarks</a>.
* </P>
+ *
+ <a name="fboGLSLVerticalFlip"><h5>FBO / GLSL Vertical Flip</h5></a>
+ 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()}.
+ If the application uses the same texture-unit, ensure it setup their texture properly, i.e. texture-unit bind, enable and then it's parameters,
+ see {@link Texture#textureCallOrder Order of Texture Commands}.
*/
@SuppressWarnings("serial")
public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol {
- private static final boolean DEBUG = Debug.debug("GLJPanel");
- 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);
+ private static final boolean DEBUG;
+ private static final boolean DEBUG_VIEWPORT;
+ private static final boolean USE_GLSL_TEXTURE_RASTERIZER;
/** Indicates whether the Java 2D OpenGL pipeline is requested by user. */
private static final boolean java2dOGLEnabledByProp;
@@ -145,11 +152,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private static boolean java2DGLPipelineOK;
static {
+ Debug.initSingleton();
+ DEBUG = Debug.debug("GLJPanel");
+ DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true);
+ USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true);
+
boolean enabled = false;
final String sVal = System.getProperty("sun.java2d.opengl");
if( null != sVal ) {
enabled = Boolean.valueOf(sVal);
}
+ Debug.initSingleton();
java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true);
enabled = false;
@@ -212,6 +225,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private int viewportX;
private int viewportY;
+ private int requestedTextureUnit = 0; // default
+
// The backend in use
private volatile Backend backend;
@@ -731,6 +746,40 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return factory;
}
+ /**
+ * Returns the used texture unit, i.e. a value of [0..n], or -1 if non used.
+ * <p>
+ * If implementation uses a texture-unit, it will be known only after the first initialization, i.e. display call.
+ * </p>
+ * <p>
+ * See <a href="#fboGLSLVerticalFlip">FBO / GLSL Vertical Flip</a>.
+ * </p>
+ */
+ public final int getTextureUnit() {
+ final Backend b = backend;
+ if ( null == b ) {
+ return -1;
+ }
+ return b.getTextureUnit();
+ }
+
+ /**
+ * Allows user to request a texture unit to be used,
+ * must be called before the first initialization, i.e. {@link #display()} call.
+ * <p>
+ * Defaults to <code>0</code>.
+ * </p>
+ * <p>
+ * See <a href="#fboGLSLVerticalFlip">FBO / GLSL Vertical Flip</a>.
+ * </p>
+ *
+ * @param v requested texture unit
+ * @see #getTextureUnit()
+ */
+ public final void setTextureUnit(int v) {
+ requestedTextureUnit = v;
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
@@ -947,6 +996,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// 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
public GLCapabilitiesImmutable getChosenGLCapabilities();
@@ -987,7 +1039,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private GLDrawableImpl offscreenDrawable;
private FBObject fboFlipped;
private GLSLTextureRaster glslTextureRaster;
- private final int fboTextureUnit = 0;
private GLContextImpl offscreenContext;
private boolean flipVertical;
@@ -1035,12 +1086,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode();
helper.setAutoSwapBufferMode(false);
final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable;
+ fboDrawable.setTextureUnit( GLJPanel.this.requestedTextureUnit );
try {
fboFlipped = new FBObject();
fboFlipped.reset(gl, fboDrawable.getWidth(), fboDrawable.getHeight(), 0, false);
fboFlipped.attachTexture2D(gl, 0, chosenCaps.getAlphaBits()>0);
// fboFlipped.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
- glslTextureRaster = new GLSLTextureRaster(fboTextureUnit, true);
+ glslTextureRaster = new GLSLTextureRaster(fboDrawable.getTextureUnit(), true);
glslTextureRaster.init(gl.getGL2ES2());
glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, fboDrawable.getWidth(), fboDrawable.getHeight());
} catch (Exception ex) {
@@ -1210,7 +1262,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
fboDrawable.swapBuffers();
fboFlipped.bind(gl);
- // gl.glActiveTexture(fboDrawable.getTextureUnit()); // implicit!
+ // gl.glActiveTexture(GL.GL_TEXTURE0 + fboDrawable.getTextureUnit()); // implicit by GLFBODrawableImpl: swapBuffers/contextMadeCurent -> swapFBOImpl
gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName());
// gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH!
glslTextureRaster.display(gl.getGL2ES2());
@@ -1244,6 +1296,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// correctness on all platforms
}
}
+
+ @Override
+ public int getTextureUnit() {
+ if(null != glslTextureRaster && null != offscreenDrawable) { // implies flippedVertical
+ return ((GLFBODrawable)offscreenDrawable).getTextureUnit();
+ }
+ return -1;
+ }
@Override
public void doPaintComponent(Graphics g) {
@@ -1446,6 +1506,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
+ public int getTextureUnit() { return -1; }
+
+ @Override
public GLCapabilitiesImmutable getChosenGLCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return new GLCapabilities(null);
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/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java
index f87f1bb3f..b88a09b71 100644
--- a/src/jogl/classes/jogamp/opengl/Debug.java
+++ b/src/jogl/classes/jogamp/opengl/Debug.java
@@ -68,16 +68,19 @@ public class Debug extends PropertyAccess {
System.err.println("JOGL implementation vendor " + p.getImplementationVendor());
}
}
+
+ /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */
+ public static final void initSingleton() {}
- public static boolean verbose() {
+ public static final boolean verbose() {
return verbose;
}
- public static boolean debugAll() {
+ public static final boolean debugAll() {
return debugAll;
}
- public static boolean debug(String subcomponent) {
+ public static final boolean debug(String subcomponent) {
return debugAll() || isPropertyDefined("jogl.debug." + subcomponent, true);
}
}
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/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
index 78ab7cc93..17646cc7b 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
@@ -87,6 +87,13 @@ import com.jogamp.common.util.IntLongHashMap;
*/
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
@@ -95,8 +102,7 @@ public class GLBufferSizeTracker {
// pattern of buffer objects indicates that the fact that this map
// never shrinks is probably not that bad.
private IntLongHashMap bufferSizeMap;
- protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true);
-
+
public GLBufferSizeTracker() {
bufferSizeMap = new IntLongHashMap();
bufferSizeMap.setKeyNotFoundValue(0xFFFFFFFFFFFFFFFFL);
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
index 7f5316fbd..890c82c90 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
@@ -76,7 +76,13 @@ import com.jogamp.common.util.IntIntHashMap;
*/
public class GLBufferStateTracker {
- protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true);
+ protected static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true);
+ }
+
// Maps binding targets to buffer objects. A null value indicates
// that the binding is unknown. A zero value indicates that it is
// known that no buffer is bound to the target, according to the
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index d6f97662e..996a47590 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;
@@ -67,6 +68,7 @@ import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GL3ES3;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDebugListener;
@@ -261,6 +263,17 @@ public abstract class GLContextImpl extends GLContext {
}
@Override
+ public final GL getRootGL() {
+ GL _gl = gl;
+ GL _parent = _gl.getDownstreamGL();
+ while ( null != _parent ) {
+ _gl = _parent;
+ _parent = _gl.getDownstreamGL();
+ }
+ return _gl;
+ }
+
+ @Override
public final GL getGL() {
return gl;
}
@@ -277,6 +290,11 @@ public abstract class GLContextImpl extends GLContext {
return gl;
}
+ @Override
+ public final int getDefaultVAO() {
+ return defaultVAO;
+ }
+
/**
* Call this method to notify the OpenGL context
* that the drawable has changed (size or position).
@@ -396,9 +414,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 GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3();
+ gl3es3.glBindVertexArray(0);
+ gl3es3.glDeleteVertexArrays(1, tmp, 0);
defaultVAO = 0;
}
glDebugHandler.enable(false);
@@ -633,16 +652,12 @@ public abstract class GLContextImpl extends GLContext {
final boolean created;
try {
created = createImpl(shareWith); // may throws exception if fails!
- 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
- // to avoid INVALID_OPERATION at VertexAttribPointer.
- // More clear is GL 4.3 core spec: 10.4 (p 307).
+ if( created && hasNoDefaultVAO() ) {
final int[] tmp = new int[1];
- gl.getGL2GL3().glGenVertexArrays(1, tmp, 0);
+ final GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3();
+ gl3es3.glGenVertexArrays(1, tmp, 0);
defaultVAO = tmp[0];
- gl.getGL2GL3().glBindVertexArray(defaultVAO);
+ gl3es3.glBindVertexArray(defaultVAO);
}
} finally {
if (null != shareWith) {
@@ -671,7 +686,7 @@ public abstract class GLContextImpl extends GLContext {
if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile
final int reqMajor;
final int reqProfile;
- if( ctxVersion.compareTo(Version30) <= 0 ) {
+ if( ctxVersion.compareTo(Version300) <= 0 ) {
reqMajor = 2;
} else {
reqMajor = ctxVersion.getMajor();
@@ -836,6 +851,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 +920,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 +948,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 +958,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 +1021,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 +1037,7 @@ public abstract class GLContextImpl extends GLContext {
}
}
- if(!GLContext.decrementGLVersion(major, minor)) {
+ if(!GLContext.decrementGLVersion(ctxOptionFlags, major, minor)) {
break;
}
}
@@ -1040,11 +1058,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 +1105,27 @@ public abstract class GLContextImpl extends GLContext {
*/
return gl;
}
+
+ /**
+ * Finalizes GL instance initialization after this context has been initialized.
+ * <p>
+ * Method calls 'void finalizeInit()' of instance 'gl' as retrieved by reflection, if exist.
+ * </p>
+ */
+ 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,24 +1136,24 @@ public abstract class GLContextImpl extends GLContext {
* ie for GLXExt, EGLExt, ..
*/
public abstract ProcAddressTable getPlatformExtProcAddressTable();
-
+
/**
- * 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
+ * Part of <code>GL_NV_vertex_array_range</code>.
+ * <p>
+ * Provides platform-independent access to the <code>wglAllocateMemoryNV</code> /
+ * <code>glXAllocateMemoryNV</code>.
+ * </p>
*/
- public void bindPbufferToTexture() { throw new GLException("not implemented"); }
+ public abstract ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority);
/**
- * 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 void releasePbufferFromTexture() { throw new GLException("not implemented"); }
-
- public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3);
+ * Part of <code>GL_NV_vertex_array_range</code>.
+ * <p>
+ * Provides platform-independent access to the <code>wglFreeMemoryNV</code> /
+ * <code>glXFreeMemoryNV</code>.
+ * </p>
+ */
+ 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
@@ -1224,7 +1263,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);
}
}
@@ -1260,6 +1299,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
@@ -1291,7 +1335,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));
}
@@ -1352,7 +1396,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 || ( glIntMajor[0]==major && glIntMinor[0]<minor ) || 0 == major ) {
if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort!
if(DEBUG) {
@@ -1407,8 +1451,8 @@ public abstract class GLContextImpl extends GLContext {
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-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);
@@ -1484,13 +1528,31 @@ 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( ( major > 4 || major == 4 && minor >= 3 ) ||
+ ( ( major > 3 || major == 3 && minor >= 1 ) && isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) ) {
+ // See GLContext.isGLES3CompatibleAvailable(..)/isGLES3Compatible()
+ // Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ 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 ;
}
@@ -1500,6 +1562,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
@@ -1515,8 +1579,8 @@ public abstract class GLContextImpl extends GLContext {
int i = 0;
final String MesaSP = "Mesa ";
- final String MesaRendererAMDsp = " AMD ";
- final String MesaRendererIntelsp = "Intel(R)";
+ // final String MesaRendererAMDsp = " AMD ";
+ // 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 isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium ");
@@ -1605,7 +1669,7 @@ public abstract class GLContextImpl extends GLContext {
//
final int quirk = GLRendererQuirks.DontCloseX11Display;
if( glRenderer.contains(MesaSP) ) {
- if ( glRenderer.contains("X11") && vendorVersion.compareTo(Version80) < 0 ) {
+ if ( glRenderer.contains("X11") && vendorVersion.compareTo(Version800) < 0 ) {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer + ", Version=[vendor " + vendorVersion + ", GL " + glVersion+"]");
}
@@ -1649,16 +1713,13 @@ public abstract class GLContextImpl extends GLContext {
}
quirks[i++] = quirk;
}
- if( ( (glRenderer.contains( MesaRendererIntelsp ) && compatCtx) || glRenderer.contains( MesaRendererAMDsp ) ) &&
- ( major > 3 || major == 3 && minor >= 1 )
- )
- {
- // FIXME: Apply vendor version constraints!
- final int quirk = GLRendererQuirks.GLNonCompliant;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
- }
- quirks[i++] = quirk;
+ if (compatCtx && (major > 3 || (major == 3 && minor >= 1))) {
+ // FIXME: Apply vendor version constraints!
+ final int quirk = GLRendererQuirks.GLNonCompliant;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ }
+ quirks[i++] = quirk;
}
if( Platform.getOSType() == Platform.OSType.WINDOWS && glRenderer.contains("SVGA3D") )
{
@@ -1790,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));
}
@@ -1832,7 +1893,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));
}
@@ -1908,10 +1969,6 @@ public abstract class GLContextImpl extends GLContext {
return glStateTracker;
}
- public final boolean isDefaultVAO(int vao) {
- return defaultVAO == vao;
- }
-
//---------------------------------------------------------------------------
// Helpers for context optimization where the last context is left
// current on the OpenGL worker thread
@@ -2017,7 +2074,7 @@ public abstract class GLContextImpl extends GLContext {
public final int getContextCreationFlags() {
return additionalCtxCreationFlags;
}
-
+
@Override
public final void setContextCreationFlags(int flags) {
if(!isCreated()) {
@@ -2060,7 +2117,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);
}
@@ -2069,7 +2126,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);
}
@@ -2079,7 +2136,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/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/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 8be910c1a..5418fbaf3 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -62,8 +62,13 @@ import javax.media.opengl.GLRunnable;
methods to be able to share it between GLAutoDrawable implementations like GLAutoDrawableBase, GLCanvas and GLJPanel. */
public class GLDrawableHelper {
/** true if property <code>jogl.debug.GLDrawable.PerfStats</code> is defined. */
- private static final boolean PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true);
+ private static final boolean PERF_STATS;
+ static {
+ Debug.initSingleton();
+ PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true);
+ }
+
protected static final boolean DEBUG = GLDrawableImpl.DEBUG;
private final Object listenersLock = new Object();
private final ArrayList<GLEventListener> listeners = new ArrayList<GLEventListener>();
diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
index 27024d4e1..3833e6852 100644
--- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
@@ -37,8 +37,14 @@ import com.jogamp.opengl.JoglVersion;
* @see GLDrawableImpl#getDefaultReadFramebuffer()
*/
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);
+ protected static final boolean DEBUG;
+ protected static final boolean DEBUG_SWAP;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject");
+ DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true);
+ }
private final GLDrawableImpl parent;
private GLCapabilitiesImmutable origParentChosenCaps;
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/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
index cea3ac4ab..e4187b35b 100644
--- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
+++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
@@ -110,7 +110,7 @@ public class GLVersionNumber extends VersionNumberString {
String str;
{
final GLVersionNumber glv = create(versionString);
- str = versionString.substring(glv.endOfStringMatch());
+ str = versionString.substring(glv.endOfStringMatch()).trim();
}
while ( str.length() > 0 ) {
@@ -120,7 +120,7 @@ public class GLVersionNumber extends VersionNumberString {
if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component!
return version;
}
- str = str.substring( eosm );
+ str = str.substring( eosm ).trim();
} else {
break; // no match
}
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..5d99e3eba 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -84,17 +84,21 @@ import com.jogamp.opengl.GLRendererQuirks;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
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);
+ /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK;
+
+ static {
+ Debug.initSingleton();
+ QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true);
+ }
private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null;
private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null;
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 +257,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 +275,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 +329,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
@Override
public GLRendererQuirks getRendererQuirks() {
- return null != rendererQuirksES2 ? rendererQuirksES2 : rendererQuirksES1 ;
+ return null != rendererQuirksES3ES2 ? rendererQuirksES3ES2 : rendererQuirksES1 ;
}
}
@@ -353,18 +364,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 +410,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 +457,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 +493,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 +593,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 +614,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 +633,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 +644,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;
@@ -663,7 +708,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/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<String> 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.*;
+/**
+ * <p>
+ * Covering ES3 and ES2.
+ * </p>
+ */
public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
protected EGLES2DynamicLibraryBundleInfo() {
super();
@@ -40,18 +45,33 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl
{
final List<String> libsGL = new ArrayList<String>();
- // 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..6787ef500 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;
@@ -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;
@@ -142,7 +141,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,12 +419,18 @@ 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();
final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
@@ -459,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) {
@@ -846,7 +842,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/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<MacOSXCGLContext>(osxCtx));
} else {
for(int i=0; i<createdContexts.size(); ) {
- final WeakReference<MacOSXCGLContext> 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<createdContexts.size(); ) {
- final WeakReference<MacOSXCGLContext> 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/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/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 806befe06..33b5b3b20 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -226,9 +226,15 @@ 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_ALPHA; tif=GL.GL_ALPHA; break;
- case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break;
- case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break;
+ 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);
}
setTextureFormat(tif, tf);
@@ -410,9 +416,9 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl {
" vec2 v_off = vec2("+tc_w_1+", 0.5);\n"+
" vec2 tc_half = texCoord*0.5;\n"+
" float y,u,v,r,g,b;\n"+
- " y = texture2D(image, texCoord).a;\n"+
- " u = texture2D(image, u_off+tc_half).a;\n"+
- " v = texture2D(image, v_off+tc_half).a;\n"+
+ " y = texture2D(image, texCoord).r;\n"+
+ " u = texture2D(image, u_off+tc_half).r;\n"+
+ " v = texture2D(image, v_off+tc_half).r;\n"+
" y = 1.1643*(y-0.0625);\n"+
" u = u-0.5;\n"+
" v = v-0.5;\n"+
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 f4f20ac7c..2e924cbfb 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -66,7 +66,13 @@ import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
* </p>
*/
public class FixedFuncPipeline {
- protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true);
+ protected static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true);
+ }
+
/** The maximum texture units which could be used, depending on {@link ShaderSelectionMode}. */
public static final int MAX_TEXTURE_UNITS = 8;
public static final int MAX_LIGHTS = 8;
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java
index e88a95a33..0fffc85b1 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java
@@ -1,5 +1,7 @@
package jogamp.opengl.util.pngj;
+import java.util.HashMap;
+
/**
* Internal PNG predictor filter, or strategy to select it.
*
@@ -26,15 +28,18 @@ public enum FilterType {
*/
FILTER_PAETH(4),
/**
- * Default strategy: select one of the above filters depending on global image parameters
+ * Default strategy: select one of the above filters depending on global
+ * image parameters
*/
FILTER_DEFAULT(-1),
/**
- * Aggressive strategy: select one of the above filters trying each of the filters (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!)
+ * Very aggressive strategy: select one of the above filters trying each of
+ * the filters (for every row!)
*/
FILTER_VERYAGGRESSIVE(-3),
/**
@@ -52,12 +57,17 @@ public enum FilterType {
this.val = val;
}
- public static FilterType getByVal(int i) {
+ private static HashMap<Integer, FilterType> byVal;
+
+ static {
+ byVal = new HashMap<Integer, FilterType>();
for (FilterType ft : values()) {
- if (ft.val == i)
- return ft;
+ byVal.put(ft.val, ft);
}
- return null;
+ }
+
+ public static FilterType getByVal(int i) {
+ return byVal.get(i);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java
index 26562ef3e..e62134cd5 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java
@@ -3,7 +3,8 @@ package jogamp.opengl.util.pngj;
/**
* Simple immutable wrapper for basic image info.
* <p>
- * Some parameters are redundant, but the constructor receives an 'orthogonal' subset.
+ * Some parameters are redundant, but the constructor receives an 'orthogonal'
+ * subset.
* <p>
* ref: http://www.w3.org/TR/PNG/#11IHDR
*/
@@ -23,14 +24,15 @@ public class ImageInfo {
public final int rows;
/**
- * Bits per sample (per channel) in the buffer (1-2-4-8-16). This is 8-16 for RGB/ARGB images, 1-2-4-8 for
- * grayscale. For indexed images, number of bits per palette index (1-2-4-8)
+ * Bits per sample (per channel) in the buffer (1-2-4-8-16). This is 8-16
+ * for RGB/ARGB images, 1-2-4-8 for grayscale. For indexed images, number of
+ * bits per palette index (1-2-4-8)
*/
public final int bitDepth;
/**
- * Number of channels, as used internally: 3 for RGB, 4 for RGBA, 2 for GA (gray with alpha), 1 for grayscale 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;
@@ -50,7 +52,8 @@ public class ImageInfo {
public final boolean indexed;
/**
- * Flag: true if image internally uses less than one byte per sample (bit depth 1-2-4)
+ * Flag: true if image internally uses less than one byte per sample (bit
+ * depth 1-2-4)
*/
public final boolean packed;
@@ -75,10 +78,12 @@ public class ImageInfo {
public final int samplesPerRow;
/**
- * 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)
+ * 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)
* <p>
- * This equals the number of elements in the scanline array if working with packedMode=true
+ * This equals the number of elements in the scanline array if working with
+ * packedMode=true
* <p>
* For internal use, client code should rarely access this.
*/
@@ -99,7 +104,8 @@ public class ImageInfo {
* @param rows
* Height in pixels
* @param bitdepth
- * Bits per sample, in the buffer : 8-16 for RGB true color and greyscale
+ * Bits per sample, in the buffer : 8-16 for RGB true color and
+ * greyscale
* @param alpha
* Flag: has an alpha channel (RGBA or GA)
* @param grayscale
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java
index 9f8a13230..e34e6a226 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java
@@ -5,7 +5,8 @@ import jogamp.opengl.util.pngj.ImageLineHelper.ImageLineStats;
/**
* Lightweight wrapper for an image scanline, used for read and write.
* <p>
- * This object can be (usually it is) reused while iterating over the image lines.
+ * This object can be (usually it is) reused while iterating over the image
+ * lines.
* <p>
* See <code>scanline</code> field, to understand the format.
*/
@@ -18,21 +19,25 @@ public class ImageLine {
private int rown = 0;
/**
- * The 'scanline' is an array of integers, corresponds to an image line (row).
+ * The 'scanline' is an array of integers, corresponds to an image line
+ * (row).
* <p>
- * Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each <code>int</code> is a "sample" (one for
- * channel), (0-255 or 0-65535) in the corresponding PNG sequence: <code>R G B R G B...</code> or
+ * Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each
+ * <code>int</code> is a "sample" (one for channel), (0-255 or 0-65535) in
+ * the corresponding PNG sequence: <code>R G B R G B...</code> or
* <code>R G B A R G B A...</tt>
* or <code>g g g ...</code> or <code>i i i</code> (palette index)
* <p>
- * For bitdepth=1/2/4 , and if samplesUnpacked=false, each value is a PACKED byte!
+ * For bitdepth=1/2/4 , and if samplesUnpacked=false, each value is a PACKED
+ * byte!
* <p>
- * To convert a indexed line to RGB balues, see <code>ImageLineHelper.palIdx2RGB()</code> (you can't do the reverse)
+ * To convert a indexed line to RGB balues, see
+ * <code>ImageLineHelper.palIdx2RGB()</code> (you can't do the reverse)
*/
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}
+ * 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;
@@ -53,10 +58,11 @@ public class ImageLine {
public final SampleType sampleType;
/**
- * true: each element of the scanline array represents a sample always, even for internally packed PNG formats
+ * 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
+ * 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;
@@ -70,11 +76,14 @@ public class ImageLine {
/**
*
* @param imgInfo
- * Inmutable ImageInfo, basic parameter of the image we are reading or writing
+ * 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
+ * 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
+ * If true, we use unpacked format, even for packed original
+ * images
*
*/
public ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode) {
@@ -226,7 +235,10 @@ public class ImageLine {
}
}
- /** size original: samplesPerRow sizeFinal: samplesPerRowPacked (trailing elements are trash!) **/
+ /**
+ * 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)
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java
index 98f235662..91516a704 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java
@@ -5,11 +5,14 @@ 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.
+ * Bunch of utility static methods to process/analyze an image line at the pixel
+ * level.
* <p>
- * Not essential at all, some methods are probably to be removed if future releases.
+ * Not essential at all, some methods are probably to be removed if future
+ * releases.
* <p>
- * WARNING: most methods for getting/setting values work currently only for integer base imageLines
+ * WARNING: most methods for getting/setting values work currently only for
+ * integer base imageLines
*/
public class ImageLineHelper {
@@ -18,7 +21,8 @@ public class ImageLineHelper {
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
+ * 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
@@ -26,7 +30,8 @@ public class ImageLineHelper {
* Palette chunk
* @param buf
* Preallocated array, optional
- * @return R G B (A), one sample 0-255 per array element. Ready for pngw.writeRowInt()
+ * @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;
@@ -53,9 +58,12 @@ public class ImageLineHelper {
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
+ * 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],
@@ -71,8 +79,8 @@ public class ImageLineHelper {
}
/**
- * 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)
+ * 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
@@ -237,9 +245,11 @@ public class ImageLineHelper {
/**
* Unpacks scanline (for bitdepth 1-2-4) into a array <code>int[]</code>
* <p>
- * You can (OPTIONALLY) pass an preallocated array, that will be filled and returned. If null, it will be allocated
+ * You can (OPTIONALLY) pass an preallocated array, that will be filled and
+ * returned. If null, it will be allocated
* <p>
- * If <code>scale==true<code>, it scales the value (just a bit shift) towards 0-255.
+ * If
+ * <code>scale==true<code>, it scales the value (just a bit shift) towards 0-255.
* <p>
* You probably should use {@link ImageLine#unpackToNewImageLine()}
*
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java
index 1e0ab746a..feb50e7b6 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java
@@ -3,10 +3,12 @@ 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.
+ * 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)}
+ * 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 {
@@ -23,7 +25,8 @@ public class ImageLines {
public final byte[][] scanlinesb;
/**
- * Allocates a matrix to store {@code nRows} image rows. See {@link ImageLine} and {@link PngReader#readRowsInt()}
+ * Allocates a matrix to store {@code nRows} image rows. See
+ * {@link ImageLine} and {@link PngReader#readRowsInt()}
* {@link PngReader#readRowsByte()}
*
* @param imgInfo
@@ -54,8 +57,9 @@ public class ImageLines {
}
/**
- * 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
+ * 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;
@@ -86,9 +90,11 @@ public class ImageLines {
* 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
+ * 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)
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java
index 63edf8d17..a950c6b33 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java
@@ -144,18 +144,23 @@ public class PngHelperInternal {
}
}
- public static void skipBytes(InputStream is, int len) {
- byte[] buf = new byte[8192 * 4];
- int read, remain = len;
+ public static void skipBytes(InputStream is, long 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;
+ while (len > 0) {
+ long n1 = is.skip(len);
+ if (n1 > 0) {
+ len -= n1;
+ } else if (n1 == 0) { // should we retry? lets read one byte
+ if (is.read() == -1) // EOF
+ break;
+ else
+ len--;
+ } else
+ // negative? this should never happen but...
+ throw new IOException("skip() returned a negative value ???");
}
} catch (IOException e) {
- throw new PngjInputException("error reading (skipping)", e);
+ throw new PngjInputException(e);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java
index 6cc39b0e6..cdad09809 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java
@@ -37,7 +37,8 @@ class PngIDatChunkInputStream extends InputStream {
List<IdatChunkInfo> foundChunksInfo = new ArrayList<IdatChunkInfo>();
/**
- * Constructor must be called just after reading length and id of first IDAT chunk
+ * Constructor must be called just after reading length and id of first IDAT
+ * chunk
**/
PngIDatChunkInputStream(InputStream iStream, int lenFirstChunk, long offset) {
this.offset = offset;
@@ -95,7 +96,8 @@ class PngIDatChunkInputStream extends InputStream {
}
/**
- * sometimes last row read does not fully consumes the chunk here we read the reamaing dummy bytes
+ * sometimes last row read does not fully consumes the chunk here we read
+ * the reamaing dummy bytes
*/
void forceChunkEnd() {
if (!ended) {
@@ -108,7 +110,8 @@ class PngIDatChunkInputStream extends InputStream {
}
/**
- * This can return less than len, but never 0 Returns -1 if "pseudo file" ended prematurely. That is our error.
+ * This can return less than len, but never 0 Returns -1 if "pseudo file"
+ * ended prematurely. That is our error.
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
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.
- * <p>
- * The reading sequence is as follows: <br>
- * 1. At construction time, the header and IHDR chunk are read (basic image info) <br>
- * 2. Afterwards you can set some additional global options. Eg. {@link #setUnpackedMode(boolean)},
- * {@link #setCrcCheckDisabled()}.<br>
- * 3. Optional: If you call getMetadata() or getChunksLisk() before start reading the rows, all the chunks before IDAT
- * are automatically loaded and available <br>
- * 4a. The rows are read onen by one of the <tt>readRowXXX</tt> 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)<br>
- * 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.<br>
- * 5. Read of the last row auyomatically loads the trailing chunks, and ends the reader.<br>
- * 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<String> 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
- * <p>
- * 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.
- * <p>
- * See also <code>FileHelper.createPngReader(File f)</code> 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
- * <p>
- * Position before: after IDHR (crc included) Position after: just after the first IDAT chunk id
- * <P>
- * This can be called several times (tentatively), it does nothing if already run
- * <p>
- * (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<String>(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.
- * <p>
- * The default behaviour is print to stderr, but it can be overriden.
- * <p>
- * 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)
- * <p>
- * 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
- * <p>
- *
- * @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
- * <p>
- * 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.
- * <p>
- * You can pass (optionally) a prealocatted buffer.
- * <p>
- * 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.
- * <p>
- * You can pass (optionally) a prealocatted buffer.
- * <p>
- * If the bitdepth is less than 8, the bytes are packed - unless {@link #unpackedMode} is true. <br>
- * If the bitdepth is 16, the least significant byte is lost.
- * <p>
- *
- * @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.
- * <p>
- * This it's more efficient (speed an memory) that doing calling readRowInt() for each desired line only if the
- * image is interlaced.
- * <p>
- * 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.
- * <p>
- * This it's more efficient (speed an memory) that doing calling readRowByte() for each desired line only if the
- * image is interlaced.
- * <p>
- * 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). <br>
- * 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).<br>
- * 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). <br>
- * 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. <br>
- * 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
- * <p>
- * 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"<br>
- * If false (default) packed types (bitdepth=1,2 or 4) will keep several samples packed in one element (byte or int) <br>
- * 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. <br>
- * 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.
+ * <p>
+ * The reading sequence is as follows: <br>
+ * 1. At construction time, the header and IHDR chunk are read (basic image
+ * info) <br>
+ * 2. Afterwards you can set some additional global options. Eg.
+ * {@link #setUnpackedMode(boolean)}, {@link #setCrcCheckDisabled()}.<br>
+ * 3. Optional: If you call getMetadata() or getChunksLisk() before start
+ * reading the rows, all the chunks before IDAT are automatically loaded and
+ * available <br>
+ * 4a. The rows are read onen by one of the <tt>readRowXXX</tt> 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)<br>
+ * 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.<br>
+ * 5. Read of the last row auyomatically loads the trailing chunks, and ends the
+ * reader.<br>
+ * 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<String> 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
+ * <p>
+ * 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.
+ * <p>
+ * See also <code>FileHelper.createPngReader(File f)</code> 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
+ * <p>
+ * Position before: after IDHR (crc included) Position after: just after the
+ * first IDAT chunk id
+ * <P>
+ * This can be called several times (tentatively), it does nothing if
+ * already run
+ * <p>
+ * (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<String>(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.
+ * <p>
+ * The default behaviour is print to stderr, but it can be overriden.
+ * <p>
+ * 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)
+ * <p>
+ * 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
+ * <p>
+ *
+ * @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
+ * <p>
+ * 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.
+ * <p>
+ * You can pass (optionally) a prealocatted buffer.
+ * <p>
+ * 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.
+ * <p>
+ * You can pass (optionally) a prealocatted buffer.
+ * <p>
+ * If the bitdepth is less than 8, the bytes are packed - unless
+ * {@link #unpackedMode} is true. <br>
+ * If the bitdepth is 16, the least significant byte is lost.
+ * <p>
+ *
+ * @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.
+ * <p>
+ * This it's more efficient (speed an memory) that doing calling
+ * readRowInt() for each desired line only if the image is interlaced.
+ * <p>
+ * 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.
+ * <p>
+ * This it's more efficient (speed an memory) that doing calling
+ * readRowByte() for each desired line only if the image is interlaced.
+ * <p>
+ * 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). <br>
+ * 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).<br>
+ * 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). <br>
+ * 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. <br>
+ * 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
+ * <p>
+ * 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"<br>
+ * If false (default) packed types (bitdepth=1,2 or 4) will keep several
+ * samples packed in one element (byte or int) <br>
+ * 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. <br>
+ * 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/PngWriter.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java
index 601cd96c0..3e684a881 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java
@@ -83,8 +83,9 @@ public class PngWriter {
}
/**
- * 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.
+ * 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.
* <p>
* See also <code>FileHelper.createPngWriter()</code> if available.
*
@@ -418,13 +419,15 @@ public class PngWriter {
/**
* Copies first (pre IDAT) ancillary chunks from a PngReader.
* <p>
- * Should be called when creating an image from another, before starting writing lines, to copy relevant chunks.
+ * Should be called when creating an image from another, before starting
+ * writing lines, to copy relevant chunks.
* <p>
*
* @param reader
* : PngReader object, already opened.
* @param copy_mask
- * : Mask bit (OR), see <code>ChunksToWrite.COPY_XXX</code> constants
+ * : Mask bit (OR), see <code>ChunksToWrite.COPY_XXX</code>
+ * constants
*/
public void copyChunksFirst(PngReader reader, int copy_mask) {
copyChunks(reader, copy_mask, false);
@@ -433,14 +436,15 @@ public class PngWriter {
/**
* Copies last (post IDAT) ancillary chunks from a PngReader.
* <p>
- * Should be called when creating an image from another, after writing all lines, before closing the writer, to copy
- * additional chunks.
+ * Should be called when creating an image from another, after writing all
+ * lines, before closing the writer, to copy additional chunks.
* <p>
*
* @param reader
* : PngReader object, already opened and fully read.
* @param copy_mask
- * : Mask bit (OR), see <code>ChunksToWrite.COPY_XXX</code> constants
+ * : Mask bit (OR), see <code>ChunksToWrite.COPY_XXX</code>
+ * constants
*/
public void copyChunksLast(PngReader reader, int copy_mask) {
copyChunks(reader, copy_mask, true);
@@ -449,8 +453,8 @@ public class PngWriter {
/**
* Computes compressed size/raw size, approximate.
* <p>
- * Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow +
- * 1).
+ * Actually: compressed size = total size of IDAT data , raw size =
+ * uncompressed pixel bytes = rows * (bytesPerRow + 1).
*
* This must be called after pngw.end()
*/
@@ -463,7 +467,8 @@ public class PngWriter {
}
/**
- * Finalizes the image creation and closes the stream. This MUST be called after writing the lines.
+ * Finalizes the image creation and closes the stream. This MUST be called
+ * after writing the lines.
*/
public void end() {
if (rowNum != imgInfo.rows - 1)
@@ -525,15 +530,17 @@ public class PngWriter {
* See also setCompLevel()
*
* @param filterType
- * One of the five prediction types or strategy to choose it (see <code>PngFilterType</code>) Recommended
- * values: DEFAULT (default) or AGGRESIVE
+ * One of the five prediction types or strategy to choose it (see
+ * <code>PngFilterType</code>) 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
+ * Sets maximum size of IDAT fragments. This has little effect on
+ * performance you should rarely call this
* <p>
*
* @param idatMaxSize
@@ -553,7 +560,8 @@ public class PngWriter {
}
/**
- * Deflater strategy: one of Deflater.FILTERED Deflater.HUFFMAN_ONLY Deflater.DEFAULT_STRATEGY
+ * Deflater strategy: one of Deflater.FILTERED Deflater.HUFFMAN_ONLY
+ * Deflater.DEFAULT_STRATEGY
* <p>
* Default: Deflater.FILTERED . This should be changed very rarely.
*/
@@ -562,8 +570,8 @@ public class PngWriter {
}
/**
- * Writes line, checks that the row number is consistent with that of the ImageLine See writeRow(int[] newrow, int
- * rown)
+ * 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)
*/
@@ -607,18 +615,22 @@ public class PngWriter {
/**
* Writes a full image row.
* <p>
- * 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.
+ * 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.
* <p>
- * Warning: the array might be modified in some cases (unpacked row with low bitdepth)
+ * Warning: the array might be modified in some cases (unpacked row with low
+ * bitdepth)
* <p>
*
* @param newrow
- * Array of pixel values. Warning: the array size should be exact (samplesPerRowP)
+ * 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
+ * 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);
@@ -627,8 +639,9 @@ public class PngWriter {
}
/**
- * 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)
+ * 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)
*/
@@ -659,12 +672,15 @@ public class PngWriter {
}
/**
- * If false (default), and image has bitdepth 1-2-4, the scanlines passed are assumed to be already packed.
+ * If false (default), and image has bitdepth 1-2-4, the scanlines passed
+ * are assumed to be already packed.
* <p>
- * If true, each element is a sample, the writer will perform the packing if necessary.
+ * If true, each element is a sample, the writer will perform the packing if
+ * necessary.
* <p>
- * Warning: when using {@link #writeRow(ImageLine, int)} (recommended) the <tt>packed</tt> flag of the ImageLine
- * object overrides (and overwrites!) this field.
+ * Warning: when using {@link #writeRow(ImageLine, int)} (recommended) the
+ * <tt>packed</tt> 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
index 963abc50e..c429b893b 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java
@@ -1,7 +1,8 @@
package jogamp.opengl.util.pngj;
/**
- * Exception for anomalous internal problems (sort of asserts) that point to some issue with the library
+ * Exception for anomalous internal problems (sort of asserts) that point to
+ * some issue with the library
*
* @author Hernan J Gonzalez
*
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java
index 0801e33bb..f68458d19 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjUnsupportedException.java
@@ -1,7 +1,8 @@
package jogamp.opengl.util.pngj;
/**
- * Exception thrown because of some valid feature of PNG standard that this library does not support
+ * Exception thrown because of some valid feature of PNG standard that this
+ * library does not support
*/
public class PngjUnsupportedException extends RuntimeException {
private static final long serialVersionUID = 1L;
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java
index a5bad666c..4516a0886 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java
@@ -4,7 +4,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
- * stream that outputs to memory and allows to flush fragments every 'size' bytes to some other destination
+ * stream that outputs to memory and allows to flush fragments every 'size'
+ * bytes to some other destination
*/
abstract class ProgressiveOutputStream extends ByteArrayOutputStream {
private final int size;
@@ -50,8 +51,8 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream {
}
/**
- * if it's time to flush data (or if forced==true) calls abstract method flushBuffer() and cleans those bytes from
- * own buffer
+ * if it's time to flush data (or if forced==true) calls abstract method
+ * flushBuffer() and cleans those bytes from own buffer
*/
private final void checkFlushBuffer(boolean forced) {
while (forced || count >= size) {
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<PngChunk> filterList(List<PngChunk> target, ChunkPredicate predicateKeep) {
- List<PngChunk> result = new ArrayList<PngChunk>();
- 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<PngChunk> target, ChunkPredicate predicateRemove) {
- Iterator<PngChunk> 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<Inflater> inflaterProvider = new ThreadLocal<Inflater>() {
+ protected Inflater initialValue() {
+ return new Inflater();
+ }
+ };
+
+ private static final ThreadLocal<Deflater> deflaterProvider = new ThreadLocal<Deflater>() {
+ 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<PngChunk> filterList(List<PngChunk> target, ChunkPredicate predicateKeep) {
+ List<PngChunk> result = new ArrayList<PngChunk>();
+ 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<PngChunk> target, ChunkPredicate predicateRemove) {
+ Iterator<PngChunk> 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/ChunkLoadBehaviour.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java
index 03d50c2c4..82ab3bcf9 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java
@@ -1,7 +1,8 @@
package jogamp.opengl.util.pngj.chunks;
/**
- * Defines gral strategy about what to do with ancillary (non-critical) chunks when reading
+ * Defines gral strategy about what to do with ancillary (non-critical) chunks
+ * when reading
*/
public enum ChunkLoadBehaviour {
/**
@@ -9,7 +10,8 @@ public enum ChunkLoadBehaviour {
*/
LOAD_CHUNK_NEVER,
/**
- * Ancillary chunks are loaded only if 'known' (registered with the factory).
+ * Ancillary chunks are loaded only if 'known' (registered with the
+ * factory).
*/
LOAD_CHUNK_KNOWN,
/**
@@ -19,7 +21,8 @@ public enum ChunkLoadBehaviour {
LOAD_CHUNK_IF_SAFE,
/**
* Load all chunks. <br>
- * Notice that other restrictions might apply, see PngReader.skipChunkMaxSize PngReader.skipChunkIds
+ * 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/ChunkRaw.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java
index 8dd0ef476..3aba26cca 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java
@@ -13,13 +13,15 @@ import jogamp.opengl.util.pngj.PngjOutputException;
/**
* Raw (physical) chunk.
* <p>
- * Short lived object, to be created while serialing/deserializing Do not reuse it for different chunks. <br>
+ * Short lived object, to be created while serialing/deserializing Do not reuse
+ * it for different chunks. <br>
* 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.
+ * 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;
@@ -29,12 +31,14 @@ public class ChunkRaw {
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
+ * 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.
+ * 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;
@@ -71,7 +75,8 @@ public class ChunkRaw {
}
/**
- * Computes the CRC and writes to the stream. If error, a PngjOutputException is thrown
+ * Computes the CRC and writes to the stream. If error, a
+ * PngjOutputException is thrown
*/
public void writeChunk(OutputStream os) {
if (idbytes.length != 4)
@@ -85,8 +90,8 @@ public class ChunkRaw {
}
/**
- * position before: just after chunk id. positon after: after crc Data should be already allocated. Checks CRC
- * Return number of byte read.
+ * 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, boolean checkCrc) {
PngHelperInternal.readBytes(is, data, 0, 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
index ad788f154..5ce94ff9f 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java
@@ -49,8 +49,8 @@ public class ChunksList {
}
/**
- * Returns a copy of the list (but the chunks are not copied) <b> This should not be used for general metadata
- * handling
+ * Returns a copy of the list (but the chunks are not copied) <b> This
+ * should not be used for general metadata handling
*/
public ArrayList<PngChunk> getChunks() {
return new ArrayList<PngChunk>(chunks);
@@ -96,7 +96,8 @@ public class ChunksList {
}
/**
- * If innerid!=null and the chunk is PngChunkTextVar or PngChunkSPLT, it's filtered by that id
+ * 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
@@ -119,8 +120,9 @@ public class ChunksList {
/**
* Returns only one chunk or null if nothing found - does not include queued
* <p>
- * 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)
+ * 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);
@@ -129,8 +131,9 @@ public class ChunksList {
/**
* Returns only one chunk or null if nothing found - does not include queued
* <p>
- * 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)
+ * 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<? extends PngChunk> list = getById(id, innerid);
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java
index 204c4c2a5..e76456ad4 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java
@@ -13,7 +13,8 @@ import jogamp.opengl.util.pngj.PngjOutputException;
public class ChunksListForWrite extends ChunksList {
/**
- * chunks not yet writen - does not include IHDR, IDAT, END, perhaps yes PLTE
+ * chunks not yet writen - does not include IHDR, IDAT, END, perhaps yes
+ * PLTE
*/
private final List<PngChunk> queuedChunks = new ArrayList<PngChunk>();
@@ -67,8 +68,9 @@ public class ChunksListForWrite extends ChunksList {
/**
* 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!
+ * 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);
@@ -87,7 +89,8 @@ public class ChunksListForWrite extends ChunksList {
}
/**
- * this should be called only for ancillary chunks and PLTE (groups 1 - 3 - 5)
+ * 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)
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 1d630591e..a45979ec2 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java
@@ -12,13 +12,16 @@ import jogamp.opengl.util.pngj.PngjExceptionInternal;
* Represents a instance of a PNG chunk.
* <p>
* See <a
- * href="http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html">http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks
- * .html</a> </a>
+ * href="http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html">http://www
+ * .libpng.org/pub/png/spec/1.2/PNG-Chunks .html</a> </a>
* <p>
- * Concrete classes should extend {@link PngChunkSingle} or {@link PngChunkMultiple}
+ * Concrete classes should extend {@link PngChunkSingle} or
+ * {@link PngChunkMultiple}
* <p>
- * Note that some methods/fields are type-specific (getOrderingConstraint(), allowsMultiple()),<br>
- * some are 'almost' type-specific (id,crit,pub,safe; the exception is PngUKNOWN), <br>
+ * Note that some methods/fields are type-specific (getOrderingConstraint(),
+ * allowsMultiple()),<br>
+ * some are 'almost' type-specific (id,crit,pub,safe; the exception is
+ * PngUKNOWN), <br>
* and the rest are instance-specific
*/
public abstract class PngChunk {
@@ -35,8 +38,9 @@ public abstract class PngChunk {
protected final ImageInfo imgInfo;
/**
- * 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.
+ * 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 {
/**
@@ -83,8 +87,8 @@ public abstract class PngChunk {
/**
* This static map defines which PngChunk class correspond to which ChunkID
* <p>
- * The client can add other chunks to this map statically, before reading an image, calling
- * PngChunk.factoryRegister(id,class)
+ * The client can add other chunks to this map statically, before reading an
+ * image, calling PngChunk.factoryRegister(id,class)
*/
private final static Map<String, Class<? extends PngChunk>> factoryMap = new HashMap<String, Class<? extends PngChunk>>();
static {
@@ -114,8 +118,9 @@ public abstract class PngChunk {
/**
* Registers a chunk-id (4 letters) to be associated with a PngChunk class
* <p>
- * 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.
+ * 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<? extends PngChunk> chunkClass) {
factoryMap.put(chunkId, chunkClass);
@@ -124,9 +129,11 @@ public abstract class PngChunk {
/**
* True if the chunk-id type is known.
* <p>
- * A chunk is known if we recognize its class, according with <code>factoryMap</code>
+ * A chunk is known if we recognize its class, according with
+ * <code>factoryMap</code>
* <p>
- * This is not necessarily the same as being "STANDARD", or being implemented in this library
+ * This is not necessarily the same as being "STANDARD", or being
+ * implemented in this library
* <p>
* Unknown chunks will be parsed as instances of {@link PngChunkUNKNOWN}
*/
@@ -143,7 +150,8 @@ public abstract class PngChunk {
}
/**
- * This factory creates the corresponding chunk and parses the raw chunk. This is used when reading.
+ * 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);
@@ -153,7 +161,8 @@ public abstract class PngChunk {
}
/**
- * Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known)
+ * 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;
@@ -189,7 +198,8 @@ public abstract class PngChunk {
}
/**
- * In which "chunkGroup" (see {@link ChunksList}for definition) this chunks instance was read or written.
+ * In which "chunkGroup" (see {@link ChunksList}for definition) this chunks
+ * instance was read or written.
* <p>
* -1 if not read or written (eg, queued)
*/
@@ -236,16 +246,16 @@ public abstract class PngChunk {
}
/**
- * Creates the physical chunk. This is used when writing (serialization). Each particular chunk class implements its
- * own logic.
+ * 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.
+ * 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);
@@ -254,7 +264,8 @@ public abstract class PngChunk {
* <p>
* This is used when copying chunks from a reader to a writer
* <p>
- * It should normally be a deep copy, and after the cloning this.equals(other) should return true
+ * It should normally be a deep copy, and after the cloning
+ * this.equals(other) should return true
*/
public abstract void cloneDataFromRead(PngChunk other);
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 b816db205..911513c0d 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java
@@ -7,7 +7,8 @@ import jogamp.opengl.util.pngj.ImageInfo;
* <p>
* see http://www.w3.org/TR/PNG/#11IDAT
* <p>
- * This is dummy placeholder - we write/read this chunk (actually several) by special code.
+ * 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;
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java
index 696edd431..d44250a2f 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java
@@ -17,7 +17,8 @@ public abstract class PngChunkMultiple extends PngChunk {
}
/**
- * NOTE: this chunk uses the default Object's equals() hashCode() implementation.
+ * NOTE: this chunk uses the default Object's equals() hashCode()
+ * implementation.
*
* This is the right thing to do, normally.
*
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java
index 286f39db0..5247169e0 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java
@@ -3,7 +3,8 @@ 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.
+ * PNG chunk type (abstract) that does not allow multiple instances in same
+ * image.
*/
public abstract class PngChunkSingle extends PngChunk {
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.
- * <p>
- * see http://www.w3.org/TR/PNG/#11tRNS
- * <p>
- * 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.
+ * <p>
+ * see http://www.w3.org/TR/PNG/#11tRNS
+ * <p>
+ * 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;
+ }
+
+}
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 52d1b22c1..ecf8b98c3 100644
--- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java
+++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java
@@ -7,13 +7,13 @@ 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.
+ * We consider "image metadata" every info inside the image except for the most
+ * basic image info (IHDR chunk - ImageInfo class) and the pixels values.
* <p>
* This includes the palette (if present) and all the ancillary chunks
* <p>
- * 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
+ * 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 ChunksList chunkList;
@@ -31,8 +31,9 @@ public class PngMetadata {
/**
* Queues the chunk at the writer
* <p>
- * 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.
+ * 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 void queueChunk(final PngChunk c, boolean lazyOverwrite) {
ChunksListForWrite cl = getChunkListW();
@@ -87,7 +88,8 @@ public class PngMetadata {
* Creates a time chunk with current time, less secsAgo seconds
* <p>
*
- * @return Returns the created-queued chunk, just in case you want to examine or modify it
+ * @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);
@@ -104,7 +106,8 @@ public class PngMetadata {
* Creates a time chunk with diven date-time
* <p>
*
- * @return Returns the created-queued chunk, just in case you want to examine or modify it
+ * @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);
@@ -137,7 +140,8 @@ public class PngMetadata {
* (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
+ * @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)
@@ -180,7 +184,8 @@ public class PngMetadata {
}
/**
- * Returns empty if not found, concatenated (with newlines) if multiple! - and trimmed
+ * Returns empty if not found, concatenated (with newlines) if multiple! -
+ * and trimmed
* <p>
* Use getTxtsForKey() if you don't want this behaviour
*/
@@ -204,7 +209,8 @@ public class PngMetadata {
}
/**
- * Creates a new empty palette chunk, queues it for write and return it to the caller, who should fill its entries
+ * 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);
@@ -222,7 +228,8 @@ public class PngMetadata {
}
/**
- * Creates a new empty TRNS chunk, queues it for write and return it to the caller, who should fill its entries
+ * 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);
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index 4444e9d63..bf2d3fa47 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -80,7 +80,7 @@ public class WGLGLCapabilities extends GLCapabilities {
public static final String PFD2String(PIXELFORMATDESCRIPTOR pfd, int pfdID) {
final int dwFlags = pfd.getDwFlags();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean sep = false;
if( 0 != (GDI.PFD_DRAW_TO_WINDOW & dwFlags ) ) {
@@ -270,4 +270,4 @@ public class WGLGLCapabilities extends GLCapabilities {
sink.append(": ");
return super.toString(sink);
}
-} \ No newline at end of file
+}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java
index f1598d580..3e788d286 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java
@@ -51,6 +51,7 @@ public class WGLUtil {
public static final boolean USE_WGLVersion_Of_5WGLGDIFuncSet;
static {
+ Debug.initSingleton();
USE_WGLVersion_Of_5WGLGDIFuncSet = Debug.isPropertyDefined("jogl.windows.useWGLVersionOf5WGLGDIFuncSet", true);
if(USE_WGLVersion_Of_5WGLGDIFuncSet) {
System.err.println("Use WGL version of 5 WGL/GDI functions.");
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/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
index 8b8cb2052..741e671eb 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
@@ -51,7 +51,13 @@ import jogamp.opengl.GLDynamicLookupHelper;
public abstract class WindowsWGLDrawable extends GLDrawableImpl {
- private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true);
+ private static final boolean PROFILING;
+
+ static {
+ Debug.initSingleton();
+ PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true);
+ }
+
private static final int PROFILING_TICKS = 200;
private int profilingSwapBuffersTicks;
private long profilingSwapBuffersTime;
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/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index c37bcee50..4bfe0cb86 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -524,16 +524,6 @@ public class X11GLXContext extends GLContextImpl {
}
@Override
- public boolean isExtensionAvailable(String glExtensionName) {
- if (glExtensionName.equals(GLExtensions.ARB_pbuffer) ||
- glExtensionName.equals(GLExtensions.ARB_pixel_format)) {
- return getGLDrawable().getFactory().canCreateGLPbuffer(
- drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice() );
- }
- return super.isExtensionAvailable(glExtensionName);
- }
-
- @Override
protected boolean setSwapIntervalImpl(int interval) {
if( !drawable.getChosenGLCapabilities().isOnscreen() ) { return false; }
@@ -633,11 +623,16 @@ 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();
sb.append(getClass().getSimpleName());
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/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/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 8e83eda33..f2a8e2394 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -366,7 +366,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
return msg.toString();
}
- /** Return a textual representation of this object's on/off screen state. Use the given StringBuffer [optional]. */
+ /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */
protected StringBuilder onoffScreenToString(StringBuilder sink) {
if(null == sink) {
sink = new StringBuilder();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
index b801ab457..85659f286 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
@@ -130,7 +130,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C
@Override
int hashCode();
- /** Return a textual representation of this object. Use the given StringBuffer [optional]. */
+ /** Return a textual representation of this object. Use the given StringBuilder [optional]. */
StringBuilder toString(StringBuilder sink);
/** Returns a textual representation of this object. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
index 744c7e6d5..4f07bca9b 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
@@ -66,8 +66,13 @@ import jogamp.nativewindow.Debug;
*/
public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
- private static final boolean DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true);
+ private static final boolean DEBUG;
+ static {
+ Debug.initSingleton();
+ DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true);
+ }
+
private final static int NO_SCORE = -9999999;
private final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
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.<br>
* This initialization method <b>must be called</b> once by the program or utilizing modules!
diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/javax/media/nativewindow/package.html
index 14730a548..3fe42bab0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/package.html
+++ b/src/nativewindow/classes/javax/media/nativewindow/package.html
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
- <title>NativeWindow Protocol Draft Public Review Specification</title>
+ <title>NativeWindow Specification Overview</title>
</head>
<body>
@@ -10,7 +10,7 @@
<h3>Preface</h3>
This specification, an optional set of packages, describing a <i>protocol</i> for a
<i>native windowing interface</i> binding to Java(TM).<br>
- Currently specified <i>native windowing systems</i> are:<br><br>
+ Currently specified <i>native windowing systems</i> are:
<ul>
<li> EGL/OpenKODE Windowing System</li>
<li> X11 Windowing System</li>
@@ -20,95 +20,79 @@
</ul>
<br>
However, any other native windowing system may be added to the implementation,
- using a generic string identifier and an optional specialisation of:<br><br>
+ using a generic string identifier and an optional specialisation of:
<ul>
- <li>{@link javax.media.nativewindow.AbstractGraphicsDevice AbstractGraphicsDevice},<br>
- <br>
- Shall return the new string identifier with {@link javax.media.nativewindow.AbstractGraphicsDevice#getType() getType()}</li>
+ <li>{@link javax.media.nativewindow.AbstractGraphicsDevice AbstractGraphicsDevice},
+ <p>Shall return the new string identifier with {@link javax.media.nativewindow.AbstractGraphicsDevice#getType() getType()}</p></li>
<li>{@link javax.media.nativewindow.AbstractGraphicsScreen AbstractGraphicsScreen}</li>
<li>{@link javax.media.nativewindow.AbstractGraphicsConfiguration AbstractGraphicsConfiguration}</li>
</ul>
- <br>
- The implementor has to provide the following:<br><br>
+ <p>The implementor has to provide the following:</p>
<ul>
- <li> The specialisation of the abstract class {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}<br>
- <br>
- shall be registered with {@link javax.media.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.</li>
+ <li> The specialisation of the abstract class {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}
+ <p>shall be registered with {@link javax.media.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.</p></li>
- <li> The specialisation of the abstract class {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}<br>
- <br>
- shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</li>
- </ul><br>
- This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native surface to an implementation of
- and window to an implementation of {@link javax.media.nativewindow.NativeSurface NativeSurface}.<br>
- {@link javax.media.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.<br>
- However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.<br>
+ <li> The specialisation of the abstract class {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+ <p>shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</p></li>
+ </ul>
+ <p>This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native surface to an implementation of
+ and window to an implementation of {@link javax.media.nativewindow.NativeSurface NativeSurface}.</p>
+ <p>{@link javax.media.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.</p>
+ <p>However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.</p>
<h3>Dependencies</h3>
This binding has dependencies to the following:
<ul>
- <li> Either of the following Java implementations:<br/>
+ <li> Either of the following Java implementations:
<ul>
- <li> <a href="http://java.sun.com/j2se/1.5.0/docs/api/">Java SE 1.5 or later</a> </li>
- <li> A mobile JavaVM with language 1.5 support, ie:
+ <li> <a href="http://docs.oracle.com/javase/6/docs/api/">Java SE 1.6 or later</a> </li>
+ <li> A mobile JavaVM with language 1.6 support, ie:
<ul>
- <li> <a href="http://developer.android.com/reference/packages.html">Dalvik API Level 7</a> </li>
+ <li> <a href="http://developer.android.com/reference/packages.html">Android API Level 9 (Version 2.3)</a> </li>
<li> <a href="http://jamvm.sourceforge.net/">JamVM</a> </li>
</ul>
with
<ul>
- <li> <a href="http://java.sun.com/products/foundation/">Foundation Profile 1.1.2 (JSR 219)</a> </li>
- <li> <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/package-summary.html"> Java 1.4 <i>java.nio</i> implementation</a> </li>
+ <li> <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/package-summary.html"> Java 1.4 <i>java.nio</i> implementation</a> </li>
</ul></li>
</ul></li>
</ul>
<br>
<h3>Package Structure</h3>
- The packages defined by this specification include:<br/><br/>
+ The packages defined by this specification include:
<ul>
- <li>The <b>javax.media.nativewindow</b> package<br>
- <br>
- This package contains Java bindings for a native windowing system.<br>
- Subsequent packages contain marker type classes, containing native characteristics of the windowing system.
-
- <ul>
- <li>The <b>javax.media.nativewindow.awt</b> package<br>
- <br>
- This sub package contains classes to cover the native characteristics of the AWT windowing system.</li>
+ <li>The <b>javax.media.nativewindow</b> package
+ <p>This package contains Java bindings for a native windowing system.</p>
+ <p>Subsequent packages contain marker type classes, containing native characteristics of the windowing system.</p>
+ <ul>
+ <li>The <b>javax.media.nativewindow.awt</b> package
+ <p>This sub package contains classes to cover the native characteristics of the AWT windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.x11</b> package<br>
- <br>
- This sub package contains classes to cover the native characteristics of the X11 windowing system.</li>
+ <li>The <b>javax.media.nativewindow.x11</b> package
+ <p>This sub package contains classes to cover the native characteristics of the X11 windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.windows</b> package<br>
- <br>
- This sub package contains classes to cover the native characteristics of the Windows windowing system.</li>
+ <li>The <b>javax.media.nativewindow.windows</b> package
+ <p>This sub package contains classes to cover the native characteristics of the Windows windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.macosx</b> package<br>
- <br>
- This sub package contains classes to cover the native characteristics of the MacOSX windowing system.</li>
+ <li>The <b>javax.media.nativewindow.macosx</b> package
+ <p>This sub package contains classes to cover the native characteristics of the MacOSX windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.egl</b> package<br>
- <br>
- This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.</li>
+ <li>The <b>javax.media.nativewindow.egl</b> package
+ <p>This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.</p></li>
</ul></li>
</ul>
<h3>Factory Model</h3>
-Running on a platform with a supported windowing system, the factory model shall be used
-to instantiate a native window, see {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}.<br>
-The implementor has to specialize
-All supported
-Regardless of the knowledge of the underly
-<br>
+<p>Running on a platform with a supported windowing system, the factory model shall be used
+to instantiate a native window, see {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}.</p>
-<h3>Revision History<br>
- </h3>
+<h3>Revision History</h3>
<ul>
<li> Early Draft Review, June 2009</li>
<li> 2.0.0 Maintenance Release, February 2011</li>
+<li> 2.0.2 Major Release, July 18th 2013</li>
</ul>
<br>
<br>
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
@@ -85,6 +85,19 @@ public class Dimension implements Cloneable, DimensionImmutable {
}
@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; }
if (obj instanceof Dimension) {
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,13 +37,22 @@ import com.jogamp.common.type.WriteCloneable;
* <li><code>height</code></li>
* </ul>
*/
-public interface DimensionImmutable extends WriteCloneable {
+public interface DimensionImmutable extends WriteCloneable, Comparable<DimensionImmutable> {
int getHeight();
int getWidth();
/**
+ * <p>
+ * Compares square of size.
+ * </p>
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final DimensionImmutable d);
+
+ /**
* Checks whether two dimensions objects are equal. Two instances
* of <code>DimensionReadOnly</code> are equal if two components
* <code>height</code> and <code>width</code> are equal.
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
@@ -55,6 +55,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; }
if (obj instanceof Point) {
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,13 +32,22 @@ 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<PointImmutable> {
int getX();
int getY();
/**
+ * <p>
+ * Compares the square of the position.
+ * </p>
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final PointImmutable d);
+
+ /**
* Checks whether two points objects are equal. Two instances
* of <code>PointReadOnly</code> are equal if the two components
* <code>y</code> and <code>x</code> are equal.
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
@@ -143,6 +143,31 @@ public class Rectangle implements Cloneable, RectangleImmutable {
}
@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; }
if (obj instanceof Rectangle) {
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<RectangleImmutable> {
int getHeight();
@@ -62,6 +62,15 @@ public interface RectangleImmutable extends WriteCloneable {
float coverage(RectangleImmutable r);
/**
+ * <p>
+ * Compares square of size 1st, if equal the square of position.
+ * </p>
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final RectangleImmutable d);
+
+ /**
* Checks whether two rect objects are equal. Two instances
* of <code>Rectangle</code> are equal if the four integer values
* of the fields <code>y</code>, <code>x</code>,
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:<br>
+/**
+ * Immutable SurfaceSize Class, consisting of it's read only components:<br>
* <ul>
* <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in pixels</li>
* <li><code>bits per pixel</code></li>
* </ul>
*/
-public class SurfaceSize {
+public class SurfaceSize implements Comparable<SurfaceSize> {
final DimensionImmutable resolution;
final int bitsPerPixel;
@@ -60,6 +61,27 @@ public class SurfaceSize {
}
/**
+ * <p>
+ * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel.
+ * </p>
+ * {@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 <code>SurfaceSize</code> are equal if the two components
* <code>resolution</code> and <code>bitsPerPixel</code>
diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java
index 95547c971..c5e316364 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java
@@ -69,15 +69,18 @@ public class Debug extends PropertyAccess {
}
}
- public static boolean verbose() {
+ /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */
+ public static final void initSingleton() {}
+
+ public static final boolean verbose() {
return verbose;
}
- public static boolean debugAll() {
+ public static final boolean debugAll() {
return debugAll;
}
- public static boolean debug(String subcomponent) {
+ public static final boolean debug(String subcomponent) {
return debugAll() || isPropertyDefined("nativewindow.debug." + subcomponent, true);
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 2524f107a..66be82a44 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -69,7 +69,15 @@ public class AWTMisc {
return (Container) c;
}
- public static Component getNextFocus(Component comp) {
+ /**
+ * Traverse to the next forward or backward component using the
+ * container's FocusTraversalPolicy.
+ *
+ * @param comp the assumed current focuse component
+ * @param forward if true, returns the next focus component, otherwise the previous one.
+ * @return
+ */
+ public static Component getNextFocus(Component comp, boolean forward) {
Container focusContainer = comp.getFocusCycleRootAncestor();
while ( focusContainer != null &&
( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) )
@@ -80,7 +88,7 @@ public class AWTMisc {
Component next = null;
if (focusContainer != null) {
final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy();
- next = policy.getComponentAfter(focusContainer, comp);
+ next = forward ? policy.getComponentAfter(focusContainer, comp) : policy.getComponentBefore(focusContainer, comp);
if (next == null) {
next = policy.getDefaultComponent(focusContainer);
}
@@ -88,25 +96,6 @@ public class AWTMisc {
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/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index bbc58b73a..78e432b7f 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -53,6 +53,8 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice;
* Contains a thread safe X11 utility to retrieve display connections.
*/
public class X11Util implements ToolkitProperties {
+ public static final boolean DEBUG = Debug.debug("X11Util");
+
/**
* See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515
* <p>
@@ -92,7 +94,6 @@ public class X11Util implements ToolkitProperties {
*/
public static final boolean ATI_HAS_MULTITHREADING_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_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);
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index d6ddd9613..c618405c2 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;
@@ -153,41 +154,40 @@ public abstract class Display {
/**
* Sets a new {@link EDTUtil} and returns the previous one.
* <p>
- * If <code>newEDTUtil</code> is <code>null</code>,
+ * If <code>usrEDTUtil</code> is <code>null</code>,
* the device's default EDTUtil is created and used.
* </p>
* <p>
- * 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 <code>usrEDTUtil</code>,
+ * it's being stopped, wait-until-idle.
* </p>
* <p>
- * If <code>newEDTUtil</code> is not null and equals the previous one,
+ * If <code>usrEDTUtil</code> is not null and equals the previous one,
* no change is being made.
* </p>
- * <p>
- * Note that <code>newEDTUtil</code> will be started by this method,
- * if it is not running yet.
- * </p>
*/
- 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();
// Global Displays
- protected static final ArrayList<Display> displayList = new ArrayList<Display>();
+ protected static final ArrayList<WeakReference<Display>> displayList = new ArrayList<WeakReference<Display>>();
protected static int displaysActive = 0;
public static void dumpDisplayList(String prefix) {
synchronized(displayList) {
- Iterator<Display> 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<WeakReference<Display>> 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 +216,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>(display));
+ }
+ }
+
/** Returns the global display collection */
- @SuppressWarnings("unchecked")
public static Collection<Display> getAllDisplays() {
ArrayList<Display> list;
synchronized(displayList) {
- list = (ArrayList<Display>) displayList.clone();
+ list = new ArrayList<Display>();
+ 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/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.
* <p>
+ * The list is ordered in descending order,
+ * see {@link MonitorMode#compareTo(MonitorMode)}.
+ * </p>
+ * <p>
* Use w/ care, it's not a copy!
* </p>
*/
diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java
index 914aa880f..218cd8bd5 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);
* </pre>
*/
-public class MonitorMode {
+public class MonitorMode implements Comparable<MonitorMode> {
+
+ /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */
+ public static final Comparator<MonitorMode> monitorModeComparator = new Comparator<MonitorMode>() {
+ 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<MonitorMode> monitorModeComparatorInv = new Comparator<MonitorMode>() {
+ public int compare(MonitorMode mm1, MonitorMode mm2) {
+ return mm2.compareTo(mm1);
+ } };
+
/**
- * Immutable <i>surfaceSize and refreshRate</i> Class, consisting of it's read only components:<br>
+ * Immutable <i>surfaceSize, flags and refreshRate</i> Class, consisting of it's read only components:<br>
* <ul>
* <li>nativeId</li>
* <li>{@link SurfaceSize} surface memory size</li>
+ * <li><code>flags</code></li>
* <li><code>refresh rate</code></li>
* </ul>
*/
- public static class SizeAndRRate {
+ public static class SizeAndRRate implements Comparable<SizeAndRRate> {
/** 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();
}
@@ -140,8 +156,8 @@ public class MonitorMode {
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();
+ public static final StringBuilder flags2String(int flags) {
+ final StringBuilder sb = new StringBuilder();
boolean sp = false;
if( 0 != ( flags & FLAG_INTERLACE ) ) {
sb.append(STR_INTERLACE);
@@ -161,6 +177,49 @@ public class MonitorMode {
}
/**
+ * <p>
+ * Compares {@link SurfaceSize#compareTo(SurfaceSize) surfaceSize} 1st, then {@link #flags}, then {@link #refreshRate}.
+ * </p>
+ * <p>
+ * Flags are compared as follows:
+ * <pre>
+ * NONE > DOUBLESCAN > INTERLACE
+ * </pre>
+ * </p>
+ * <p>
+ * Refresh rate differences of &lt; 0.01 are considered equal (epsilon).
+ * </p>
+ * {@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:<br/>
* <ul>
@@ -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:<br/>
* <ul>
* <li><code>surfaceSize</code></li>
- * <li><code>refreshRate</code></li>
* <li><code>flags</code></li>
+ * <li><code>refreshRate</code></li>
* </ul>
*/
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;
}
}
@@ -306,6 +365,42 @@ public class MonitorMode {
}
/**
+ * <p>
+ * Compares {@link SizeAndRRate#compareTo(SizeAndRRate) sizeAndRRate} 1st, then {@link #rotation}.
+ * </p>
+ * <p>
+ * Rotation is compared inverted, i.e. <code>360 - rotation</code>,
+ * so the lowest rotation reflects a higher value.
+ * </p>
+ * <p>
+ * Order of comparing MonitorMode:
+ * <ul>
+ * <li>resolution</li>
+ * <li>bits per pixel</li>
+ * <li>flags</li>
+ * <li>refresh rate</li>
+ * <li>rotation</li>
+ * </ul>
+ * </p>
+ * {@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:<br/>
* <ul>
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index f56aff964..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;
@@ -64,7 +66,7 @@ public abstract class Screen {
}
/**
- * Manual trigger the native creation, if it is not done yet..<br>
+ * Manual trigger the native creation, if not done yet..<br>
* This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsScreen}, via
* {@link #getGraphicsScreen()}.<br>
* Otherwise the abstract device won't be available before the dependent component (Window) is realized.
@@ -164,6 +166,10 @@ public abstract class Screen {
/**
* Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s.
+ * <p>
+ * The list is ordered in descending order,
+ * see {@link MonitorMode#compareTo(MonitorMode)}.
+ * </p>
*/
public abstract List<MonitorMode> getMonitorModes();
@@ -220,7 +226,7 @@ public abstract class Screen {
public abstract void removeMonitorModeListener(MonitorModeListener sml);
// Global Screens
- protected static ArrayList<Screen> screenList = new ArrayList<Screen>();
+ protected static final ArrayList<WeakReference<Screen>> screenList = new ArrayList<WeakReference<Screen>>();
protected static int screensActive = 0;
/**
@@ -249,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>(screen));
+ }
+ }
+
+ /** Returns the global screen collection */
public static Collection<Screen> getAllScreens() {
ArrayList<Screen> list;
synchronized(screenList) {
- list = (ArrayList<Screen>) screenList.clone();
+ list = new ArrayList<Screen>();
+ 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/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.
* <p>
* 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.
+ * </p>
+ * <p>
+ * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events.
* </p>
* @param l
*/
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index dd8939e43..e4b5a25c4 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -223,7 +223,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final Set<AWTKeyStroke> fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
final Set<AWTKeyStroke> bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
if(fwdKeys.contains(ks)) {
- final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this);
+ final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, true /* forward */);
if(DEBUG) {
System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", nextFocus "+nextFocus);
}
@@ -231,7 +231,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
nextFocus.requestFocus();
suppress = true;
} else if(bwdKeys.contains(ks)) {
- final Component prevFocus = AWTMisc.getPrevFocus(NewtCanvasAWT.this);
+ final Component prevFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, false /* forward */);
if(DEBUG) {
System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", prevFocus "+prevFocus);
}
@@ -576,7 +576,9 @@ 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);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h);
+ }
newtChild.setVisible(false);
newtChild.setSize(w, h);
newtChild.reparentWindow(jawtWindow);
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index ec05a34ad..085f598dc 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -312,13 +312,13 @@ public class KeyEvent extends InputEvent
* @param isKeyChar true if <code>uniChar</code> 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[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) ||
( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) {
return false;
}
@@ -330,7 +330,7 @@ public class KeyEvent extends InputEvent
return false;
}
}
- return true;
+ return VK_UNDEFINED != uniChar;
}
/**
@@ -381,9 +381,19 @@ public class KeyEvent extends InputEvent
this.inclKeyChar = inclKeyChar;
}
};
- /** Non printable key ranges, currently fixed to an array of size 4. */
+ /**
+ * Non printable key ranges, currently fixed to an array of size 4.
+ * <p>
+ * Not included, queried upfront:
+ * <ul>
+ * <li>{@link #VK_BACK_SPACE}</li>
+ * <li>{@link #VK_TAB}</li>
+ * <li>{@link #VK_ENTER}</li>
+ * </ul>
+ * </p>
+ */
public final static NonPrintableRange[] nonPrintableKeys = {
- new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 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)
@@ -415,14 +425,14 @@ public class KeyEvent extends InputEvent
static final short VK_FREE06 = (short) 0x06;
static final short VK_FREE07 = (short) 0x07;
- /** Constant for the BACK SPACE key "\b", matching ASCII. */
+ /** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */
public static final short VK_BACK_SPACE = (short) 0x08;
- /** Constant for the HORIZ TAB key "\t", matching ASCII. */
+ /** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */
public static final short VK_TAB = (short) 0x09;
- /** Constant for the ENTER key, i.e. LINE FEED "\n", matching ASCII. */
- public static final short VK_ENTER = (short) 0x0A;
+ /** LINE_FEED "\n", matching ASCII, n/a on keyboard. */
+ static final short VK_FREE0A = (short) 0x0A;
/** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */
public static final short VK_PAGE_DOWN = (short) 0x0B;
@@ -430,7 +440,9 @@ public class KeyEvent extends InputEvent
/** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */
public static final short VK_CLEAR = (short) 0x0C;
- static final short VK_FREE0D = (short) 0x0D;
+ /** 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;
/** Constant for the CTRL function key. ASCII: shift-in. */
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index 18c8285f7..93bbcc0b9 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -252,33 +252,6 @@ public class MouseEvent extends InputEvent
}
/**
- * <i>Usually</i> a wheel rotation of <b>&gt; 0.0f is up</b>,
- * and <b>&lt; 0.0f is down</b>.
- * <p>
- * Usually a wheel rotations is considered a vertical scroll.<br/>
- * If {@link #isShiftDown()}, a wheel rotations is
- * considered a horizontal scroll, where <b>shift-up = left = &gt; 0.0f</b>,
- * and <b>shift-down = right = &lt; 0.0f</b>.
- * </p>
- * <p>
- * <i>However</i>, on some OS this might be flipped due to the OS <i>default</i> behavior.
- * The latter is true for OS X 10.7 (Lion) for example.
- * </p>
- * <p>
- * The events will be send usually in steps of one, ie. <i>-1.0f</i> and <i>1.0f</i>.
- * Higher values may result due to fast scrolling.
- * Fractional values may result due to slow scrolling with high resolution devices.
- * </p>
- * <p>
- * The button number refers to the wheel number.
- * </p>
- * @deprecated Use {@link #getRotation()}
- */
- public float getWheelRotation() {
- return isShiftDown() ? rotationXYZ[0] : rotationXYZ[1] ;
- }
-
- /**
* Returns a 3-component float array filled with the values of the rotational axis
* in the following order: horizontal-, vertical- and z-axis.
* <p>
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 345d92bc1..e85d67dea 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.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -47,6 +49,8 @@ import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
+import javax.media.opengl.GL3;
+import javax.media.opengl.GL4ES3;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
@@ -54,6 +58,8 @@ import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLES2;
+import javax.media.opengl.GLES3;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -529,6 +535,29 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
savedAnimator.resume();
}
}
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void shutdownRenderingAction() {
+ final GLAnimatorControl anim = GLWindow.this.getAnimator();
+ if ( null != anim && anim.isAnimating() ) {
+ final Thread animThread = anim.getThread();
+ if( animThread == Thread.currentThread() ) {
+ anim.stop(); // on anim thread, non-blocking
+ } else {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ if( anim.isAnimating() && null != animThread ) {
+ try {
+ animThread.stop();
+ } catch(Throwable t) {
+ }
+ }
+ return null;
+ } } );
+ }
+ }
+ }
}
//----------------------------------------------------------------------
@@ -805,14 +834,58 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
* A most simple JOGL AWT test entry
*/
public static void main(String args[]) {
+ final boolean forceES2;
+ final boolean forceES3;
+ final boolean forceGL3;
+ final boolean forceGL4ES3;
+ {
+ boolean _forceES2 = false;
+ boolean _forceES3 = false;
+ boolean _forceGL3 = false;
+ boolean _forceGL4ES3 = false;
+ if( null != args ) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-es2")) {
+ _forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ _forceES3 = true;
+ } else if(args[i].equals("-gl3")) {
+ _forceGL3 = true;
+ } else if(args[i].equals("-gl4es3")) {
+ _forceGL4ES3 = true;
+ }
+ }
+ }
+ forceES2 = _forceES2;
+ forceES3 = _forceES3;
+ forceGL3 = _forceGL3;
+ forceGL4ES3 = _forceGL4ES3;
+ }
+ System.err.println("forceES2 "+forceES2);
+ System.err.println("forceES3 "+forceES3);
+ System.err.println("forceGL3 "+forceGL3);
+ System.err.println("forceGL4ES3 "+forceGL4ES3);
+
System.err.println(VersionUtil.getPlatformInfo());
System.err.println(GlueGenVersion.getInstance());
System.err.println(JoglVersion.getInstance());
System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString());
- final GLProfile glp = GLProfile.getDefault();
+ final GLProfile glp;
+ if(forceGL4ES3) {
+ glp = GLProfile.get(GLProfile.GL4ES3);
+ } else if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getDefault();
+ }
final GLCapabilitiesImmutable caps = new GLCapabilities( glp );
+ System.err.println("Requesting: "+caps);
GLWindow glWindow = GLWindow.create(caps);
glWindow.setSize(128, 128);
@@ -824,6 +897,23 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
System.err.println(JoglVersion.getGLInfo(gl, null));
System.err.println("Requested: "+drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities());
System.err.println("Chosen : "+drawable.getChosenGLCapabilities());
+ System.err.println("GL impl. class "+gl.getClass().getName());
+ if( gl.isGL4ES3() ) {
+ GL4ES3 _gl = gl.getGL4ES3();
+ System.err.println("GL4ES3 retrieved, impl. class "+_gl.getClass().getName());
+ }
+ if( gl.isGL3() ) {
+ GL3 _gl = gl.getGL3();
+ System.err.println("GL3 retrieved, impl. class "+_gl.getClass().getName());
+ }
+ if( gl.isGLES3() ) {
+ GLES3 _gl = gl.getGLES3();
+ System.err.println("GLES3 retrieved, impl. class "+_gl.getClass().getName());
+ }
+ if( gl.isGLES2() ) {
+ GLES2 _gl = gl.getGLES2();
+ System.err.println("GLES2 retrieved, impl. class "+_gl.getClass().getName());
+ }
}
@Override
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 0183da592..e86df2084 100644
--- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
@@ -65,14 +65,19 @@ public interface EDTUtil {
public void setPollPeriod(long ms);
/**
- * Create a new EDT. One should invoke <code>reset()</code><br>
- * after <code>invokeStop(..)</code> in case another start via <code>invoke(..)</code>
- * is expected.
- *
- * @see #invoke(boolean, java.lang.Runnable)
- * @see #invokeStop(java.lang.Runnable)
+ * Starts or restarts the EDT.
+ * <p>
+ * 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()}.
+ * </p>
+ *
+ * @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)
+ * @see #waitUntilStopped()
*/
- public void reset();
+ public boolean restart() throws IllegalStateException;
/**
* Returns true if the current thread is the event dispatch thread (EDT).
@@ -107,44 +112,57 @@ 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();
/**
* Append the final task to the EDT task queue,
- * signals EDT to stop and wait until stopped.<br/>
+ * signals EDT to stop.
+ * <p>
+ * If <code>wait</code> is <code>true</code> methods
+ * blocks until EDT is stopped.
+ * </p>
+ * <p>
* <code>task</code> maybe <code>null</code><br/>
* Due to the nature of this method:
* <ul>
* <li>All previous queued tasks will be finished.</li>
* <li>No new tasks are allowed, an Exception is thrown.</li>
* <li>Can be issued from within EDT, ie from within an enqueued task.</li>
- * <li>{@link #reset()} may follow immediately, ie creating a new EDT</li>
+ * <li>{@link #restart()} may follow immediately, ie creating a new EDT</li>
* </ul>
+ * </p>
+ * @return true if <code>task</code> has been executed or queued for later execution, otherwise false
*/
- public void invokeStop(Runnable finalTask);
+ public boolean invokeStop(boolean wait, Runnable finalTask);
/**
- * Shall start the thread if not running, <code>task</code> maybe null for this purpose.<br>
- * Append task to the EDT task queue.<br>
- * Wait until execution is finished if <code>wait == true</code>.<br>
+ * Appends task to the EDT task queue if current thread is not EDT,
+ * otherwise execute task immediately.
+ * <p>
+ * Wait until execution is finished if <code>wait == true</code>.
+ * </p>
* Can be issued from within EDT, ie from within an enqueued task.<br>
- *
- * @throws RuntimeException in case EDT is stopped and not {@link #reset()}
+ * @return true if <code>task</code> 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.<br>
* 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.<br>
- * No <code>stop</code> action is performed, {@link #invokeStop(java.lang.Runnable)} should be used before.
+ * No <code>stop</code> action is performed, {@link #invokeStop(boolean, java.lang.Runnable)} should be used before.
+ * <p>
+ * If caller thread is EDT or NEDT, this call will not block.
+ * </p>
+ * @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/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<MonitorMode> monitorModes, boolean ascendingOrder) {
+ if( ascendingOrder ) {
+ Collections.sort(monitorModes);
+ } else {
+ Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv);
+ }
+ }
+
/**
*
* @param monitorModes
diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java
index 676d9b758..4b0a98216 100644
--- a/src/newt/classes/jogamp/newt/Debug.java
+++ b/src/newt/classes/jogamp/newt/Debug.java
@@ -69,15 +69,18 @@ public class Debug extends PropertyAccess {
}
}
- public static boolean verbose() {
+ /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */
+ public static final void initSingleton() {}
+
+ public static final boolean verbose() {
return verbose;
}
- public static boolean debugAll() {
+ public static final boolean debugAll() {
return debugAll;
}
- public static boolean debug(String subcomponent) {
+ public static final boolean debug(String subcomponent) {
return debugAll() || isPropertyDefined("newt.debug." + subcomponent, true);
}
}
diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
index 651522799..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,31 +76,34 @@ public class DefaultEDTUtil implements EDTUtil {
}
@Override
- public final void reset() {
- synchronized(edtLock) {
- waitUntilStopped();
+ public final boolean restart() throws IllegalStateException {
+ synchronized(edtLock) {
+ 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();
}
@@ -126,13 +129,13 @@ public class DefaultEDTUtil implements EDTUtil {
}
@Override
- public final void invokeStop(Runnable task) {
- invokeImpl(true, 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() {
@@ -140,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);
@@ -171,19 +172,20 @@ public class DefaultEDTUtil implements EDTUtil {
}
}
} else {
- if( !edt.isRunning() ) {
- if( !stop ) {
- startImpl();
- } 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( !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);
+ }
if(DEBUG) {
Thread.dumpStack();
}
}
- } else if(stop && null == task) {
- task = nullTask;
+ return false;
+ } else if( stop && null == task ) {
+ task = nullTask; // ensures execution triggering stop
}
if(null != task) {
@@ -220,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();
@@ -244,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<RunnableTask> tasks = new ArrayList<RunnableTask>(); // 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
@@ -282,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");
}
}
@@ -299,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 {
@@ -329,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 3edb532db..8f792b23c 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;
@@ -76,12 +77,12 @@ 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) {
if(DEBUG) {
System.err.println("Display.create() REUSE: "+display0+" "+getThreadName());
@@ -96,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();
- displayList.add(display);
+ 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
if(DEBUG) {
System.err.println("Display.create() NEW: "+display+" "+getThreadName());
@@ -136,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+")");
}
@@ -152,14 +153,14 @@ 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");
}
- 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+")");
+ }
}
}
}
@@ -178,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;
}
@@ -205,29 +204,61 @@ public abstract class DisplayImpl extends Display {
return edtUtil;
}
- private void removeEDT(final Runnable task) {
- if(null!=edtUtil) {
- edtUtil.invokeStop(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;
}
@@ -238,52 +269,67 @@ 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!
+ 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");
}
}
- /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the EDT removal blocks. */
+ /** May be utilized at a shutdown hook, impl. does not block. */
/* pp */ static final void shutdownAll() {
final int dCount = displayList.size();
if(DEBUG) {
dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName());
}
for(int i=0; i<dCount && displayList.size()>0; 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));
}
- d.removeEDT( new Runnable() {
- public void run() {
- if ( null != d.getGraphicsDevice() ) {
- d.closeNativeImpl();
+ if( null != d ) { // GC'ed ?
+ 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(f_aDevice);
+ }
+ }
+ };
+ if(null != edtUtil) {
+ final long coopSleep = edtUtil.getPollPeriod() * 2;
+ 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;
+ }
}
}
@@ -318,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() {
@@ -386,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 */
@@ -487,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;
}
@@ -544,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/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
index db31cc83f..43d558515 100644
--- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
+++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
@@ -94,20 +94,20 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
final long tStart;
if(Screen.DEBUG) {
- tStart = System.nanoTime();
+ tStart = System.currentTimeMillis();
} else {
tStart = 0;
}
sms.fireMonitorModeChangeNotify(this, mmU);
if(Screen.DEBUG) {
- System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireModeChangeNotify() "+mmU);
+ System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): fireModeChangeNotify() "+mmU);
}
-
+
boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU);
if(success) {
if(Screen.DEBUG) {
- System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(1): "+success);
+ System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): setCurrentModeImpl() "+mmU+", success(1): "+success);
}
} else {
// 2nd attempt validate!
@@ -115,7 +115,7 @@ public class MonitorDeviceImpl extends MonitorDevice {
success = queriedCurrent.hashCode() == mmU.hashCode() ;
if(Screen.DEBUG) {
System.err.println("Screen.setCurrentMode.2: queried "+queriedCurrent);
- System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(2): "+success);
+ System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): setCurrentModeImpl() "+mmU+", success(2): "+success);
}
}
if( success ) {
@@ -124,7 +124,7 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
sms.fireMonitorModeChanged(this, mmU, success);
if(Screen.DEBUG) {
- System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success);
+ System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): X.X: success "+success+": "+this);
}
return success;
} finally {
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index f63d1499e..5ffa2ebbf 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -52,9 +52,15 @@ 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);
+ protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED;
+
+ static {
+ Debug.initSingleton();
+ DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true);
+ }
public static final int default_sm_bpp = 32;
public static final int default_sm_widthmm = 519;
@@ -124,7 +130,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());
}
@@ -168,39 +174,39 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")");
} else {
tCreated = 0;
- }
-
+ }
display.addReference();
createNativeImpl();
if(null == aScreen) {
throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
}
-
+
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);
}
- ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorState(this.getFQName());
- sms.addListener(this);
}
@Override
public synchronized final void destroy() {
- releaseMonitorState();
-
synchronized(screenList) {
- screenList.remove(this);
if(0 < screensActive) {
screensActive--;
}
+ if(DEBUG) {
+ System.err.println("Screen.destroy() ("+DisplayImpl.getThreadName()+"): active "+screensActive);
+ // Thread.dumpStack();
+ }
}
if ( null != aScreen ) {
+ releaseMonitorState();
closeNativeImpl();
aScreen = null;
}
@@ -216,8 +222,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
}
if ( 0 == refCount ) {
createNative();
- }
- if(null == aScreen) {
+ } else if(null == aScreen) {
throw new NativeWindowException("Screen.addReference() (refCount "+refCount+") null AbstractGraphicsScreen");
}
return ++refCount;
@@ -285,12 +290,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);
}
}
}
@@ -397,7 +402,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<refMonitorModeListener.size(); i++) {
((MonitorModeListener)refMonitorModeListener.get(i)).monitorModeChangeNotify(me);
@@ -410,7 +415,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
final MonitorDeviceImpl monitor = (MonitorDeviceImpl) monitors.get(i);
final Rectangle newViewport = getNativeMonitorDeviceViewportImpl(monitor);
if( DEBUG ) {
- System.err.println("Screen.updateMonitorViewport["+i+"]: "+monitor.getViewport()+" -> "+newViewport);
+ System.err.println("Screen.updateMonitorViewport["+i+"] @ "+Thread.currentThread().getName()+": "+monitor.getViewport()+" -> "+newViewport);
}
if( null != newViewport ) {
monitor.setViewportValue(newViewport);
@@ -425,7 +430,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<refMonitorModeListener.size(); i++) {
((MonitorModeListener)refMonitorModeListener.get(i)).monitorModeChanged(me, success);
@@ -536,6 +541,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 ); // descending order
+ for(Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) {
+ MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false ); // descending order
+ }
if(DEBUG) {
int i=0;
for(Iterator<MonitorMode> iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) {
@@ -550,7 +560,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);
}
@@ -605,7 +615,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
return cache.monitorDevices.size();
}
- private void releaseMonitorState() {
+ private final void releaseMonitorState() {
ScreenMonitorState sms;
ScreenMonitorState.lockScreenMonitorState();
try {
@@ -663,11 +673,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName());
}
for(int i=0; i<sCount && screenList.size()>0; 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 1ac97b07c..caa461e41 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;
@@ -80,26 +81,50 @@ import jogamp.nativewindow.SurfaceUpdatedHelper;
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<WindowImpl> windowList = new ArrayList<WindowImpl>();
+ public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE;
static {
+ Debug.initSingleton();
+ DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true);
+
ScreenImpl.initSingleton();
}
-
- /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the Window destruction and EDT removal blocks. */
+
+ protected static final ArrayList<WeakReference<WindowImpl>> windowList = new ArrayList<WeakReference<WindowImpl>>();
+
+ /** Maybe utilized at a shutdown hook, impl. does not block. */
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; i<wCount && windowList.size()>0; i++) { // be safe ..
- final WindowImpl w = windowList.remove(0);
+ final WindowImpl w = windowList.remove(0).get();
+ if(DEBUG_IMPLEMENTATION) {
+ final long wh = null != w ? w.getWindowHandle() : 0;
+ System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(wh)+", GCed "+(null==w));
+ }
+ if( null != w ) {
+ w.shutdown();
+ }
+ }
+ }
+ private static void addWindow2List(WindowImpl window) {
+ synchronized(windowList) {
+ // GC before add
+ int i=0, gced=0;
+ while( i < windowList.size() ) {
+ if( null == windowList.get(i).get() ) {
+ gced++;
+ windowList.remove(i);
+ } else {
+ i++;
+ }
+ }
+ windowList.add(new WeakReference<WindowImpl>(window));
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle()));
+ System.err.println("Window.addWindow2List: GCed "+gced+", size "+windowList.size());
}
- w.markInvalid();
}
}
@@ -129,6 +154,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean fullscreen = false, brokenFocusChange = false;
private List<MonitorDevice> 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
@@ -207,9 +233,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();
@@ -232,9 +256,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);
@@ -242,12 +264,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
/** Fast invalidation of instance w/o any blocking function call. */
- private final void markInvalid() {
+ private final void shutdown() {
+ if(null!=lifecycleHook) {
+ lifecycleHook.shutdownRenderingAction();
+ }
setWindowHandle(0);
visible = false;
fullscreen = false;
fullscreenMonitors = null;
fullscreenUseMainMonitor = true;
+ fullscreenUseSpanningMode = false;
hasFocus = false;
parentWindowHandle = 0;
}
@@ -310,6 +336,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* @see #pauseRenderingAction()
*/
void resumeRenderingAction();
+
+ /**
+ * Shutdown rendering action (thread) abnormally.
+ * <p>
+ * Should be called only at shutdown, if necessary.
+ * </p>
+ */
+ void shutdownRenderingAction();
}
private boolean createNative() {
@@ -361,9 +395,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 {
@@ -551,6 +583,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.
+ * <p>
+ * Default is all but {@link #FLAG_IS_FULLSCREEN_SPAN}
+ * </p>
+ */
+ 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 ) |
@@ -881,17 +923,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);
}
@@ -926,9 +970,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) {
@@ -1004,6 +1051,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
fullscreen = false;
fullscreenMonitors = null;
fullscreenUseMainMonitor = true;
+ fullscreenUseSpanningMode = false;
hasFocus = false;
parentWindowHandle = 0;
@@ -1035,9 +1083,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);
}
@@ -1839,25 +1884,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private class FullScreenAction implements Runnable {
boolean fullscreen;
- List<MonitorDevice> monitors;
- boolean useMainMonitor;
- private boolean init(boolean fullscreen, boolean useMainMonitor, List<MonitorDevice> 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;
}
}
@@ -1872,19 +1905,27 @@ 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 == monitors ) {
- if( useMainMonitor ) {
- monitors = new ArrayList<MonitorDevice>();
- monitors.add( getMainMonitor() );
+ if( null == fullscreenMonitors ) {
+ if( fullscreenUseMainMonitor ) {
+ fullscreenMonitors = new ArrayList<MonitorDevice>();
+ 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);
+ 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();
@@ -1894,6 +1935,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
w = viewport.getWidth();
h = viewport.getHeight();
} else {
+ fullscreenUseMainMonitor = true;
+ fullscreenUseSpanningMode = false;
+ fullscreenMonitors = null;
fs_span_flag = 0;
viewport = null;
x = nfs_x;
@@ -1915,16 +1959,15 @@ 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);
+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+
+ ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName());
}
- 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;
@@ -1952,8 +1995,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);
}
@@ -1964,7 +2005,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) {
@@ -1978,7 +2019,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List<MonitorDevice> monitors) {
synchronized(fullScreenAction) {
- if( fullScreenAction.init(fullscreen, useMainMonitor, monitors) ) {
+ 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) {
@@ -1997,8 +2041,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;
@@ -2007,20 +2051,34 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private class MonitorModeListenerImpl implements MonitorModeListener {
boolean animatorPaused = false;
+ boolean hadFocus = false;
+ boolean fullscreenPaused = false;
+ List<MonitorDevice> _fullscreenMonitors = null;
+ boolean _fullscreenUseMainMonitor = true;
public void monitorModeChangeNotify(MonitorEvent me) {
+ hadFocus = hasFocus();
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.monitorModeChangeNotify: "+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: "+me+", success: "+success);
+ System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success+" @ "+Thread.currentThread().getName());
}
if(success) {
@@ -2028,7 +2086,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
@@ -2044,13 +2102,35 @@ 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();
+ 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();
@@ -2535,19 +2615,21 @@ 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);
+ if( consumedE ) {
+ System.err.println("consumeKeyEvent(kfh): "+e+", consumed: "+consumedE);
+ }
}
}
- if(DEBUG_KEY_EVENT) {
- if( !consumedE ) {
- System.err.println("consumeKeyEvent: "+e);
+ if( !consumedE ) {
+ for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) {
+ consumedE = propagateKeyEvent(e, keyListeners.get(i));
+ }
+ if(DEBUG_KEY_EVENT) {
+ System.err.println("consumeKeyEvent(usr): "+e+", consumed: "+consumedE);
}
- }
- for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) {
- consumedE = propagateKeyEvent(e, keyListeners.get(i));
}
}
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/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
index de524d54c..9f6210269 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
@@ -78,7 +78,7 @@ public class NewtVersionActivity extends NewtBaseActivity {
glWindow.addGLEventListener(new GLEventListener() {
public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
- final StringBuffer sb = new StringBuffer();
+ 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);
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
index fc9bbb848..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,24 +68,29 @@ public class AWTEDTUtil implements EDTUtil {
}
@Override
- final public void reset() {
- synchronized(edtLock) {
- waitUntilStopped();
+ public final boolean restart() throws IllegalStateException {
+ synchronized(edtLock) {
+ if( nedt.isRunning() ) {
+ 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();
@@ -110,59 +115,76 @@ public class AWTEDTUtil implements EDTUtil {
@Override
final public boolean isRunning() {
- return nedt.isRunning() ; // AWT is always running
+ return nedt.isRunning() ;
}
@Override
- public final void invokeStop(Runnable task) {
- invokeImpl(true, 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 ) {
@@ -181,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
@@ -278,10 +305,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/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/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index 60fc3ec0f..393445db0 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -79,6 +79,11 @@ public class WindowDriver extends WindowImpl {
}
hmon = MonitorFromWindow0(hWnd);
+ // Let's not trigger on HDC change, GLDrawableImpl.'s destroy/create is a nop here anyways.
+ // FIXME: Validate against EGL surface creation: ANGLE uses HWND -> fine!
+ return LOCK_SUCCESS;
+
+ /**
if( hdc_old == hdc ) {
return LOCK_SUCCESS;
}
@@ -86,7 +91,7 @@ public class WindowDriver extends WindowImpl {
System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc));
// Thread.dumpStack();
}
- return LOCK_SURFACE_CHANGED;
+ return LOCK_SURFACE_CHANGED; */
}
@Override
@@ -286,7 +291,7 @@ public class WindowDriver extends WindowImpl {
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());
+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
// Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1)
// Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0).
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/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java
index c569e5fd8..e39a6c63a 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java
@@ -29,13 +29,21 @@ 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;
import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.MonitorMode;
public interface RandR {
+ public static final VersionNumber version110 = new VersionNumber(1, 1, 0);
+ public static final VersionNumber version130 = new VersionNumber(1, 3, 0);
+ public static final VersionNumber version140 = new VersionNumber(1, 4, 0);
+ VersionNumber getVersion();
+
void dumpInfo(final long dpy, final int screen_idx);
/**
@@ -72,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 a938b4064..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;
@@ -34,20 +36,17 @@ import com.jogamp.common.util.VersionNumber;
import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.MonitorMode;
-public class RandR11 implements RandR {
+class RandR11 implements RandR {
private static final boolean DEBUG = ScreenDriver.DEBUG;
- 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() {
+ RandR11() {
}
-
+
+ @Override
+ public final VersionNumber getVersion() {
+ return version110;
+ }
+
@Override
public void dumpInfo(final long dpy, final int screen_idx) {
// NOP
@@ -336,6 +335,11 @@ public 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 d10591381..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;
@@ -43,18 +45,15 @@ import com.jogamp.newt.MonitorMode;
* MonitorDevice.id == XRR monitor-idx (not id)
* </pre>
*/
-public class RandR13 implements RandR {
+class RandR13 implements RandR {
private static final boolean DEBUG = ScreenDriver.DEBUG;
- public static VersionNumber version = new VersionNumber(1, 3, 0);
-
- public static RandR13 createInstance(VersionNumber rAndRVersion) {
- if( rAndRVersion.compareTo(version) >= 0 ) {
- return new RandR13();
- }
- return null;
- }
- private RandR13() {
+ RandR13() {
+ }
+
+ @Override
+ public final VersionNumber getVersion() {
+ return version130;
}
@Override
@@ -238,54 +237,20 @@ public 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<MonitorDevice> monitors = screen.getMonitorDevices();
- final ArrayList<RectangleImmutable> viewports = new ArrayList<RectangleImmutable>();
- for(int i=0; i<monitors.size(); i++) {
- final MonitorDevice crt = monitors.get(i);
- if( crt.getId() != monitor.getId() ) {
- System.err.println("XXX setScreenViewport: add.pre["+i+"]: "+crt.getViewport());
- viewports.add( crt.getViewport() ) ;
- } else {
- System.err.println("XXX setScreenViewport: add.new["+i+"]: "+newViewp);
- viewports.add( newViewp );
- }
- }
- final RectangleImmutable newScrnViewp = new Rectangle().union(viewports);
- System.err.println("XXX setScreenViewport: "+screen.getViewport()+" -> "+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 e1373bba5..f37556dd7 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;
@@ -54,9 +55,12 @@ 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);
+ protected static final boolean DEBUG_TEST_RANDR13_DISABLED;
static {
+ Debug.initSingleton();
+ DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true);
+
DisplayDriver.initSingleton();
}
@@ -84,11 +88,12 @@ public class ScreenDriver extends ScreenImpl {
randrVersion = new VersionNumber(v[0], v[1], 0);
}
{
- final RandR13 rAndR13 = DEBUG_TEST_RANDR13_DISABLED ? null : RandR13.createInstance(randrVersion);
- if( null != rAndR13 ) {
- rAndR = rAndR13;
+ if( !DEBUG_TEST_RANDR13_DISABLED && randrVersion.compareTo(RandR.version130) >= 0 ) {
+ rAndR = new RandR13();
+ } else if( randrVersion.compareTo(RandR.version110) >= 0 ) {
+ rAndR = new RandR11();
} else {
- rAndR = RandR11.createInstance(randrVersion);
+ rAndR = null;
}
}
if( DEBUG ) {
@@ -186,7 +191,7 @@ public class ScreenDriver extends ScreenImpl {
if( null == rAndR ) { return false; }
final long t0 = System.currentTimeMillis();
- boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
+ boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
public Boolean run(long dpy) {
return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) );
}
@@ -217,14 +222,31 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) {
- runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() {
- 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<Object>() {
+ public Object run(long dpy) {
+ rAndR.updateScreenViewport(dpy, ScreenDriver.this, vOriginSize);
+ return null;
+ } } );
+ } else */ {
+ runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() {
+ 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);
+ }
+ }
}
//----------------------------------------------------------------------
@@ -248,6 +270,14 @@ public class ScreenDriver extends ScreenImpl {
return res;
}
+ private final <T> T runWithOptTempDisplayHandle(DisplayRunnable<T> action) {
+ if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 ) {
+ return display.runWithLockedDisplayDevice(action);
+ } else {
+ return runWithTempDisplayHandle(action);
+ }
+ }
+
private static native long GetScreen0(long dpy, int scrn_idx);
private static native int getWidth0(long display, 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 786587d65..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,7 +135,19 @@ public class WindowDriver extends WindowImpl {
}
}
- protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) {
+ /**
+ * <p>
+ * X11 Window supports {@link #FLAG_IS_FULLSCREEN_SPAN}
+ * </p>
+ * {@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,18 +162,57 @@ public class WindowDriver extends WindowImpl {
_x = x;
_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) ) {
+ tempFSAlwaysOnTop = true;
+ flags |= FLAG_IS_ALWAYSONTOP;
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags));
+ }
+ } else {
+ tempFSAlwaysOnTop = false;
+ }
+ }
+ final int fflags = flags;
final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() {
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 tempFSAlwaysOnTop = false;
+ /**
+ * <p>
+ * Deal w/ tempAlwaysOnTop.
+ * </p>
+ * {@inheritDoc}
+ */
+ @Override
+ protected void focusChanged(boolean defer, boolean focusGained) {
+ 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<Object>() {
+ 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();
@@ -167,6 +220,7 @@ public class WindowDriver extends WindowImpl {
}
}
+ @Override
protected void requestFocusImpl(final boolean force) {
runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() {
public Object run(long dpy) {
@@ -214,6 +268,7 @@ public class WindowDriver extends WindowImpl {
});
}
+ @Override
protected Point getLocationOnScreenImpl(final int x, final int y) {
return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Point>() {
public Point run(long dpy) {
@@ -222,6 +277,7 @@ public class WindowDriver extends WindowImpl {
} );
}
+ @Override
protected void updateInsetsImpl(Insets insets) {
// nop - using event driven insetsChange(..)
}
@@ -270,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/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java
index 2008b5ea4..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,24 +77,39 @@ public class SWTEDTUtil implements EDTUtil {
}
@Override
- public void reset() {
- synchronized(edtLock) {
- waitUntilStopped();
+ public final boolean restart() throws IllegalStateException {
+ final boolean swtDisposed = swtDisplay.isDisposed();
+ synchronized(edtLock) {
+ if( nedt.isRunning() ) {
+ 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();
@@ -104,7 +119,7 @@ public class SWTEDTUtil implements EDTUtil {
@Override
public boolean isCurrentThreadEDT() {
- return swtDisplay.getThread() == Thread.currentThread();
+ return !swtDisplay.isDisposed() && swtDisplay.getThread() == Thread.currentThread();
}
@Override
@@ -115,66 +130,94 @@ 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
- public final void invokeStop(Runnable task) {
- invokeImpl(true, 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);
+ 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;
+ }
+ if( swtDisplay.isDisposed() ) {
+ stop = true;
}
- // 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()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt);
- // Thread.dumpStack();
+ } 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);
}
- } 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 */,
- wait ? null : System.err);
- swtDisplay.asyncExec(rTask);
}
}
if( wait ) {
@@ -193,53 +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.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 ct = Thread.currentThread();
- if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) {
- while(nedt.isRunning()) {
+ 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();
} 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
@@ -296,10 +346,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);
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/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index ac0ebf07e..4ef2459e8 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -431,6 +431,9 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags,
break;
}
}
+ if( J_VK_UNDEFINED == javaVKeyUS ) {
+ javaVKeyUS = javaVKeyXX;
+ }
}
*outJavaVKeyUS = javaVKeyUS;
diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c
index 81a6726b5..53d01a6fe 100644
--- a/src/newt/native/X11RandR11.c
+++ b/src/newt/native/X11RandR11.c
@@ -311,7 +311,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenM
/*
* Class: jogamp_newt_driver_x11_RandR11
* Method: setCurrentScreenModePollEnd0
- * Signature: (J)Z
+ * Signature: (JIII)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)
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 3f50f27a4..e6e300d2e 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; i<action_len; i++) {
if(_NET_WM_ACTION_FULLSCREEN == actions[i]) {
DBG_PRINT( "**************** X11: FS EWMH CHECK[%d]: _NET_WM_ACTION_FULLSCREEN (*)\n", i);
- res |= _NET_WM_FULLSCREEN ;
+ res |= _NET_WM_STATE_FLAG_FULLSCREEN ;
} else if(_NET_WM_ACTION_ABOVE == actions[i]) {
DBG_PRINT( "**************** X11: FS EWMH CHECK[%d]: _NET_WM_ACTION_ABOVE (*)\n", i);
- res |= _NET_WM_ABOVE ;
+ res |= _NET_WM_STATE_FLAG_ABOVE ;
}
-#ifdef VERBOSE_ON
else {
char * astr = XGetAtomName(dpy, actions[i]);
DBG_PRINT( "**************** X11: FS EWMH CHECK[%d]: %s (unused)\n", i, astr);
XFree(astr);
}
-#endif
}
DBG_PRINT( "**************** X11: FS EWMH CHECK: 0x%X\n", res);
} else {
DBG_PRINT( "**************** X11: FS EWMH CHECK: XGetWindowProperty failed: %d\n", s);
}
- // above code doesn't work reliable on KDE4 ...
- res = _NET_WM_FULLSCREEN | _NET_WM_ABOVE ;
- return res;
+#endif
+ return _NET_WM_STATE_FLAG_FULLSCREEN | _NET_WM_STATE_FLAG_ABOVE ;
}
-static Bool NewtWindows_setFullscreenEWMH (Display *dpy, Window root, Window w, int ewmhFlags, Bool isVisible, Bool enable) {
+static Bool NewtWindows_setStackingEWMHFlags (Display *dpy, Window root, Window w, int ewmhFlags, Bool isVisible, Bool enable) {
Atom _NET_WM_STATE = XInternAtom( dpy, "_NET_WM_STATE", False );
Atom _NET_WM_STATE_ABOVE = XInternAtom( dpy, "_NET_WM_STATE_ABOVE", False );
Atom _NET_WM_STATE_FULLSCREEN = XInternAtom( dpy, "_NET_WM_STATE_FULLSCREEN", False );
- int ewmhMask = NewtWindows_isFullscreenEWMHSupported(dpy, w);
+ int ewmhMask = NewtWindows_getSupportedStackingEWMHFlags(dpy, w);
+ Bool changeFullscreen = 0 != ( ( _NET_WM_STATE_FLAG_FULLSCREEN & ewmhMask ) & ewmhFlags ) ;
+ Bool changeAbove = 0 != ( ( _NET_WM_STATE_FLAG_ABOVE & ewmhMask ) & ewmhFlags ) ;
Bool res = False;
if(0 == ewmhMask) {
return res;
}
- if(!isVisible && True==enable) {
- Atom types[2]={0};
- int ntypes=0;
-
- if( 0 != ( ( _NET_WM_FULLSCREEN & ewmhMask ) & ewmhFlags ) ) {
- types[ntypes++] = _NET_WM_STATE_FULLSCREEN;
- }
- if( 0 != ( ( _NET_WM_ABOVE & ewmhMask ) & ewmhFlags ) ) {
- types[ntypes++] = _NET_WM_STATE_ABOVE;
- }
- if(ntypes>0) {
- 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;
}
+ // 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);
+ }
+ 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/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);
+ }
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index f43a933e4..59ce28408 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -428,7 +428,9 @@ public class GPUUISceneGLListener0A implements GLEventListener {
@Override
public void mouseWheelMoved(MouseEvent e) {
- zoom += 2f*e.getWheelRotation();
+ if( !e.isShiftDown() ) {
+ zoom += 2f*e.getRotation()[1]; // vertical: wheel
+ }
}
}
} \ No newline at end of file
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<num; i++) {
threads[i].start();
}
+ i=0;
synchronized (syncDone) {
while(!done(tasks)) {
try {
- syncDone.wait();
+ syncDone.wait(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
+ System.err.println(i+": "+doneDump(tasks));
+ i++;
}
}
final long t1 = System.currentTimeMillis();
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/acore/TestBug692GL3VAO.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
index 95944cd98..de5db0ae2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
@@ -152,7 +152,7 @@ public class TestBug692GL3VAO extends UITestCase {
}
private void initShaders(GL3 gl) {
final String[] vertSrc = new String[]{
- "#version 150 core\n",
+ "#version 150\n",
"in vec4 vPosition;\n",
"in vec4 vColor;\n",
"out vec4 pColor;\n",
@@ -164,7 +164,7 @@ public class TestBug692GL3VAO extends UITestCase {
vertID = createShader(gl, GL3.GL_VERTEX_SHADER, vertSrc);
final String[] fragSrc = new String[]{
- "#version 150 core\n",
+ "#version 150\n",
"in vec4 pColor;\n",
"void main() {\n",
" gl_FragColor = pColor;\n",
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 e5075bbea..387e152ce 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
@@ -82,9 +82,11 @@ public class TestFBOMRTNEWT01 extends UITestCase {
// st.setVerbose(true);
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
- "shader/bin", "fbo-mrt-1", false);
+ "shader/bin", "fbo-mrt-1", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
- "shader/bin", "fbo-mrt-1", false);
+ "shader/bin", "fbo-mrt-1", 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);
@@ -95,9 +97,11 @@ public class TestFBOMRTNEWT01 extends UITestCase {
st.attachShaderProgram(gl, sp0, false);
final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
- "shader/bin", "fbo-mrt-2", false);
+ "shader/bin", "fbo-mrt-2", true);
final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
- "shader/bin", "fbo-mrt-2", false);
+ "shader/bin", "fbo-mrt-2", true);
+ vp1.defaultShaderCustomization(gl, true, true);
+ fp1.defaultShaderCustomization(gl, true, true);
final ShaderProgram sp1 = new ShaderProgram();
sp1.add(gl, vp1, System.err);
sp1.add(gl, fp1, System.err);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
index 62e74466f..629a613e9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
@@ -42,7 +42,6 @@ import javax.media.opengl.GLProfile;
import org.junit.Assert;
import org.junit.Test;
-import org.junit.BeforeClass;
import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
@@ -144,9 +143,9 @@ public class TestGLDebug00NEWT extends UITestCase {
WindowContext winctx = createWindow(glp, true);
MyGLDebugListener myGLDebugListener = new MyGLDebugListener(
- GL2GL3.GL_DEBUG_SOURCE_API_ARB,
- GL2GL3.GL_DEBUG_TYPE_ERROR_ARB,
- GL2GL3.GL_DEBUG_SEVERITY_HIGH_ARB);
+ GL2GL3.GL_DEBUG_SOURCE_API,
+ GL2GL3.GL_DEBUG_TYPE_ERROR,
+ GL2GL3.GL_DEBUG_SEVERITY_HIGH);
winctx.context.addGLDebugListener(myGLDebugListener);
GL gl = winctx.context.getGL();
@@ -171,10 +170,10 @@ public class TestGLDebug00NEWT extends UITestCase {
Assert.assertEquals((null == glDebugExt) ? false : true, winctx.context.isGLDebugMessageEnabled());
if( winctx.context.isGLDebugMessageEnabled() ) {
- winctx.context.glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
- GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
+ winctx.context.glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION,
+ GL2GL3.GL_DEBUG_TYPE_OTHER,
dbgTstId0,
- GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, dbgTstMsg0);
+ GL2GL3.GL_DEBUG_SEVERITY_MEDIUM, dbgTstMsg0);
Assert.assertEquals(true, myGLDebugListener.received());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
index f9b566c25..5cace1eb9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
@@ -91,10 +91,10 @@ public class TestGLDebug01NEWT extends UITestCase {
if(ctx.isGLDebugMessageEnabled() && null != dbgTstMsg && 0 <= dbgTstId) {
window.invoke(true, new GLRunnable() {
public boolean run(GLAutoDrawable drawable) {
- drawable.getContext().glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
- GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
+ drawable.getContext().glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION,
+ GL2GL3.GL_DEBUG_TYPE_OTHER,
dbgTstId,
- GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, dbgTstMsg);
+ GL2GL3.GL_DEBUG_SEVERITY_MEDIUM, dbgTstMsg);
return true;
}
});
@@ -121,9 +121,9 @@ public class TestGLDebug01NEWT extends UITestCase {
GLWindow window = createWindow(glp, true);
MyGLDebugListener myGLDebugListener = new MyGLDebugListener(
- GL2GL3.GL_DEBUG_SOURCE_API_ARB,
- GL2GL3.GL_DEBUG_TYPE_ERROR_ARB,
- GL2GL3.GL_DEBUG_SEVERITY_HIGH_ARB);
+ GL2GL3.GL_DEBUG_SOURCE_API,
+ GL2GL3.GL_DEBUG_TYPE_ERROR,
+ GL2GL3.GL_DEBUG_SEVERITY_HIGH);
window.getContext().addGLDebugListener(myGLDebugListener);
window.invoke(true, new GLRunnable() {
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 d9429129b..47edf53bb 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
@@ -123,6 +123,17 @@ public class TestGLProfile01NEWT extends UITestCase {
System.out.println("GLProfile GL2ES2: "+glp);
dumpVersion(glp);
}
+
+ @Test
+ public void testGLProfileGL4ES3() 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);
+ dumpVersion(glp);
+ }
void testSpecificProfile(String glps) throws InterruptedException {
if(GLProfile.isAvailable(glps)) {
@@ -168,6 +179,11 @@ public class TestGLProfile01NEWT extends UITestCase {
testSpecificProfile(GLProfile.GLES2);
}
+ @Test
+ public void testGLES3() throws InterruptedException {
+ testSpecificProfile(GLProfile.GLES3);
+ }
+
protected void dumpVersion(GLProfile glp) throws InterruptedException {
GLCapabilities caps = new GLCapabilities(glp);
GLWindow glWindow = GLWindow.create(caps);
@@ -175,6 +191,59 @@ public class TestGLProfile01NEWT extends UITestCase {
glWindow.setTitle("TestGLProfile01NEWT");
glWindow.addGLEventListener(new DumpGLInfo());
+ glWindow.addGLEventListener(new GLEventListener() {
+
+ public void init(GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ final GLProfile glp = gl.getGLProfile();
+ System.err.println("GL impl. class "+gl.getClass().getName());
+ if( gl.isGL4() ) {
+ Assert.assertNotNull( gl.getGL4() );
+ System.err.println("GL Mapping "+glp+" -> GL4");
+ }
+ if( gl.isGL4bc() ) {
+ Assert.assertNotNull( gl.getGL4bc() );
+ System.err.println("GL Mapping "+glp+" -> GL4bc");
+ }
+ if( gl.isGL3() ) {
+ Assert.assertNotNull( gl.getGL3() );
+ System.err.println("GL Mapping "+glp+" -> GL3");
+ }
+ if( gl.isGL3bc() ) {
+ Assert.assertNotNull( gl.getGL3bc() );
+ System.err.println("GL Mapping "+glp+" -> GL3bc");
+ }
+ if( gl.isGLES3() ) {
+ Assert.assertNotNull( gl.getGLES3() );
+ System.err.println("GL Mapping "+glp+" -> GLES3");
+ }
+ if( gl.isGLES2() ) {
+ Assert.assertNotNull( gl.getGLES2() );
+ System.err.println("GL Mapping "+glp+" -> GLES2");
+ }
+ if( gl.isGL4ES3() ) {
+ Assert.assertNotNull( gl.getGL4ES3() );
+ System.err.println("GL Mapping "+glp+" -> GL4ES3");
+ }
+ if( gl.isGL2ES2() ) {
+ Assert.assertNotNull( gl.getGL2ES2() );
+ System.err.println("GL Mapping "+glp+" -> GL2ES2");
+ }
+ if( gl.isGL2ES1() ) {
+ Assert.assertNotNull( gl.getGL2ES1() );
+ 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) {
+ }
+ });
glWindow.setSize(128, 128);
glWindow.setVisible(true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
index 719d1fc9d..f8e0affa3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java
@@ -42,22 +42,20 @@ import com.jogamp.common.os.Platform;
* </p>
*/
public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT {
- static boolean mainRun = false;
-
- @Test
+
+ @Test(timeout=180000) // TO 3 min
public void test02TwoThreads() throws InterruptedException {
runJOGLTasks(2, true);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02FourThreads() throws InterruptedException {
runJOGLTasks(4, true);
}
- @Test
+ @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<args.length; i++) {
- if(args[i].equals("-normalRun")) {
- mainRun = false;
- } else if(args[i].equals("-time")) {
+ if(args[i].equals("-time")) {
i++;
try {
duration = Integer.parseInt(args[i]);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
index f2871a6e5..dfb7326df 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java
@@ -44,7 +44,7 @@ import com.jogamp.common.os.Platform;
public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT {
static boolean mainRun = false;
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02TwoThreads() throws InterruptedException {
if(!mainRun) {
System.err.println("Disabled for auto unit test until further analysis - Windows/ATI driver crash");
@@ -53,7 +53,7 @@ public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT {
runJOGLTasks(2, false);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02FourThreads() throws InterruptedException {
if(!mainRun) {
System.err.println("Disabled for auto unit test until further analysis - Windows/ATI driver crash");
@@ -62,14 +62,13 @@ public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT {
runJOGLTasks(4, false);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test16SixteenThreads() throws InterruptedException {
if(!mainRun) {
System.err.println("Disabled for auto unit test until further analysis - Windows/ATI driver crash");
return;
}
- if( !mainRun &&
- Platform.getCPUFamily() != Platform.CPUFamily.ARM &&
+ if( Platform.getCPUFamily() != Platform.CPUFamily.ARM &&
Platform.getOSType() != Platform.OSType.WINDOWS ) {
runJOGLTasks(16, false);
} else {
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..24ba59b57 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,17 +32,25 @@ 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 {
+ private static String[] args = null;
@Test
public void testMain() throws InterruptedException {
- GLWindow.main(null);
+ 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(args);
}
- public static void main(String args[]) throws IOException {
+ public static void main(String[] args) throws IOException {
+ TestMainVersionGLWindowNEWT.args = args;
String tstname = TestMainVersionGLWindowNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
index 3f97cbc54..8684ab15e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
@@ -52,7 +52,7 @@ public class TestPBufferDeadlockAWT extends UITestCase {
@BeforeClass
public static void initClass() {
- glp = GLProfile.getGL2ES2();
+ glp = GLProfile.getMaxFixedFunc(true);
Assert.assertNotNull( glp );
width = 512;
height = 512;
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
index a11978784..3599258e6 100644
--- 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
@@ -65,10 +65,18 @@ public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawable
*/
public static boolean fixedNewtDisplay = true;
- @Test(timeout=3000000)
+ @Test(timeout=180000) // TO 3 min
public void test11GLWindow2GLCanvasOnScrnGL2ES2() throws InterruptedException {
final GLCapabilities caps = getCaps(GLProfile.GL2ES2);
- if(null == caps) return;
+ if(null == caps) {
+ System.err.println("GL2ES2 n/a, test n/a.");
+ return;
+ }
+ if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) {
+ System.err.println("JAWT required offscreen, test n/a.");
+ return;
+ }
+
GLADType gladType1 = GLADType.GLWindow;
GLADType gladType2 = GLADType.GLCanvasOnscreen;
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/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 0cd45e53f..63e89952f 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
@@ -39,6 +39,7 @@ 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.JoglVersion;
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;
@@ -146,13 +147,7 @@ public class GearsES1 implements GLEventListener {
System.err.println("GearsES1 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"));
- System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
- System.err.println("GL Profile: "+gl.getGLProfile());
- System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
gl.glEnable(GL.GL_CULL_FACE);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
index 097784f67..5f0c99a3d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
@@ -115,7 +115,7 @@ public class PointsDemoES1 extends PointsDemo {
for(int j=0; j<edge; j++) {
final float x = -3+j*0.7f;
final float y = -3+i*0.7f;
- final float p = (i*edge+j)*0.5f;
+ final float p = Math.max(0.000001f, (i*edge+j)*0.5f); // no zero point size!
// System.err.println("["+j+"/"+i+"]: "+x+"/"+y+": "+p);
vertices.putf(x); vertices.putf(y); vertices.putf( 0);
pointSizes[(i*edge+j)] = p;
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 97519e7c7..3b5ba1c83 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
@@ -6,6 +6,7 @@ import javax.media.opengl.*;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.util.glsl.fixedfunc.*;
public class RedSquareES1 implements GLEventListener {
@@ -80,13 +81,7 @@ public class RedSquareES1 implements GLEventListener {
System.err.println("RedSquareES1 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"));
- System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
- System.err.println("GL Profile: "+gl.getGLProfile());
- System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
// Allocate vertex arrays
colors = Buffers.newDirectFloatBuffer(16);
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 cb3eb4351..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);
@@ -450,7 +453,9 @@ public class ElektronenMultiplizierer implements GLEventListener {
st.uniform(gl, en.setData(mEffectNumber));
st.uniform(gl, et.setData(mEffectTime));
- gl.glEnable(GL_TEXTURE_2D);
+ if( !gl.isGLcore() ) {
+ gl.glEnable(GL_TEXTURE_2D);
+ }
gl.glBindTexture(GL_TEXTURE_2D, mFrameBufferTextureID);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
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
index 9d2c73f08..add11ff8c 100644
--- 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
@@ -90,9 +90,6 @@ public class FBOMix2DemosES2 implements GLEventListener {
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();
@@ -104,19 +101,8 @@ public class FBOMix2DemosES2 implements GLEventListener {
"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]);
- }
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
sp0 = new ShaderProgram();
sp0.add(gl, vp0, System.err);
@@ -260,7 +246,9 @@ public class FBOMix2DemosES2 implements GLEventListener {
}
interleavedVBO.enableBuffer(gl, true);
- gl.glEnable(GL.GL_TEXTURE_2D);
+ if( !gl.isGLcore() ) {
+ gl.glEnable(GL.GL_TEXTURE_2D);
+ }
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
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 66a8082a6..75a25e2ad 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
@@ -27,6 +27,7 @@ import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -124,20 +125,17 @@ public class GearsES2 implements GLEventListener {
public void init(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES2.init ...");
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(verbose) {
System.err.println("GearsES2 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());
+ 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);
@@ -228,11 +226,14 @@ public class GearsES2 implements GLEventListener {
drawableHeight = height;
// Thread.dumpStack();
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
+ if( !gl.hasGLSL() ) {
+ return;
+ }
st.useProgram(gl, true);
pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
@@ -264,7 +265,10 @@ public class GearsES2 implements GLEventListener {
window.removeMouseListener(gearsMouse);
window.removeKeyListener(gearsKeys);
}
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ if( !gl.hasGLSL() ) {
+ return;
+ }
st.useProgram(gl, false);
gear1.destroy(gl);
gear1 = null;
@@ -291,7 +295,7 @@ public class GearsES2 implements GLEventListener {
}
// Get the GL corresponding to the drawable we are animating
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
final boolean hasFocus;
final Object upstreamWidget = drawable.getUpstreamWidget();
@@ -320,6 +324,9 @@ public class GearsES2 implements GLEventListener {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
}
+ if( !gl.hasGLSL() ) {
+ return;
+ }
gl.glEnable(GL.GL_CULL_FACE);
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 cd40b5c6e..b69505457 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
@@ -77,9 +77,6 @@ public class Mix2TexturesES2 implements GLEventListener {
}
}
- 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();
@@ -88,19 +85,8 @@ public class Mix2TexturesES2 implements GLEventListener {
"shader/bin", "texture01_xxx", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, Mix2TexturesES2.class, "shader",
"shader/bin", null == texUnit1 ? "texture01_xxx" : "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]);
- }
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
sp0 = new ShaderProgram();
sp0.add(gl, vp0, System.err);
@@ -172,7 +158,9 @@ public class Mix2TexturesES2 implements GLEventListener {
gl.glBindTexture(GL.GL_TEXTURE_2D, texID1);
}
- gl.glEnable(GL.GL_TEXTURE_2D);
+ if( !gl.isGLcore() ) {
+ gl.glEnable(GL.GL_TEXTURE_2D);
+ }
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
}
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 98641398d..430ea45c0 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
@@ -69,9 +69,6 @@ public class MultisampleDemoES2 implements GLEventListener {
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();
@@ -87,19 +84,8 @@ public class MultisampleDemoES2 implements GLEventListener {
"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]);
- }
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
sp0 = new ShaderProgram();
sp0.add(gl, vp0, 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 3f092e341..1ba4d126f 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,6 +27,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.glsl.ShaderCode;
@@ -64,20 +65,16 @@ public class RedSquareES2 implements GLEventListener {
public void init(GLAutoDrawable glad) {
System.err.println(Thread.currentThread()+" RedSquareES2.init ...");
- GL2ES2 gl = glad.getGL().getGL2ES2();
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
System.err.println("RedSquareES2 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + glad.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"));
- 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());
-
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ if( !gl.hasGLSL() ) {
+ System.err.println("No GLSL available, no rendering.");
+ return;
+ }
st = new ShaderState();
st.setVerbose(true);
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader",
@@ -132,11 +129,14 @@ public class RedSquareES2 implements GLEventListener {
public void display(GLAutoDrawable glad) {
long t1 = System.currentTimeMillis();
- GL2ES2 gl = glad.getGL().getGL2ES2();
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
if( clearBuffers ) {
gl.glClearColor(0, 0, 0, 0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
+ if( !gl.hasGLSL() ) {
+ return;
+ }
st.useProgram(gl, true);
// One rotation every four seconds
pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
@@ -161,7 +161,10 @@ public class RedSquareES2 implements GLEventListener {
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(glad.getHandle()));
// Thread.dumpStack();
- GL2ES2 gl = glad.getGL().getGL2ES2();
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ if( !gl.hasGLSL() ) {
+ return;
+ }
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
@@ -181,7 +184,10 @@ public class RedSquareES2 implements GLEventListener {
public void dispose(GLAutoDrawable glad) {
System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... ");
- GL2ES2 gl = glad.getGL().getGL2ES2();
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ if( !gl.hasGLSL() ) {
+ return;
+ }
st.destroy(gl);
st = null;
pmvMatrix.destroy();
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..55d0a4775 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, 1.0f };
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/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
index 25f8740d4..20c28c3ea 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
@@ -27,7 +27,6 @@
*/
package com.jogamp.opengl.test.junit.jogl.demos.es2;
-import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import javax.media.opengl.GL;
@@ -58,7 +57,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
public TextureSequenceCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) {
this.texSeq = texSource;
this.innerCube = innerCube;
- this.zoom0 = zoom0;
+ this.zoom = zoom0;
this.view_rotx = rotx;
this.view_roty = roty;
}
@@ -71,11 +70,10 @@ public class TextureSequenceCubeES2 implements GLEventListener {
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 zoom=-2.3f;
private float view_rotx = 0.0f, view_roty = 0.0f, view_rotz = 0.0f;
int[] vboNames = new int[4];
boolean innerCube;
- private ByteBuffer cubeIndices;
private final MouseListener mouseAction = new MouseAdapter() {
int lx = 0;
@@ -113,7 +111,12 @@ public class TextureSequenceCubeES2 implements GLEventListener {
int nv = Math.abs(e.getY(0)-e.getY(1));
int dy = nv - lx;
- zoom += 40f*Math.signum(dy)/(float)height;
+ {
+ final float o = zoom;
+ final float d = 40f*Math.signum(dy)/(float)height;
+ zoom += d;
+ System.err.println("zoom.d: "+o+" + "+d+" -> "+zoom);
+ }
lx = nv;
} else {
@@ -133,13 +136,16 @@ public class TextureSequenceCubeES2 implements GLEventListener {
}
}
public void mouseWheelMoved(MouseEvent e) {
- zoom += e.getWheelRotation()/10f;
- System.err.println("zoom: "+zoom);
+ System.err.println("XXX "+e);
+ if( !e.isShiftDown() ) {
+ final float o = zoom;
+ final float d = e.getRotation()[1]/10f; // vertical: wheel
+ zoom += d;
+ System.err.println("zoom.w: "+o+" + "+d+" -> "+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";
@@ -149,20 +155,12 @@ public class TextureSequenceCubeES2 implements GLEventListener {
"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);
- }
+ rsVp.defaultShaderCustomization(gl, true, true);
+ int rsFpPos = rsFp.addGLSLVersion(gl);
+
rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub());
- if(gl.isGLES2()) {
- rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
- }
+ rsFpPos = rsFp.addDefaultShaderPrecision(gl, rsFpPos);
+
final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName);
rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
@@ -185,7 +183,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
st.attachShaderProgram(gl, sp, false);
}
- GLArrayDataServer interleavedVBO;
+ GLArrayDataServer interleavedVBO, cubeIndicesVBO;
public void init(GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -258,7 +256,15 @@ public class TextureSequenceCubeES2 implements GLEventListener {
interleavedVBO.seal(gl, true);
interleavedVBO.enableBuffer(gl, false);
st.ownAttribute(interleavedVBO, true);
- cubeIndices = ByteBuffer.wrap(s_cubeIndices);
+
+ cubeIndicesVBO = GLArrayDataServer.createData(6, GL.GL_UNSIGNED_SHORT, 6, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
+ for(int i=0; i<6*6; i++) {
+ cubeIndicesVBO.puts(s_cubeIndices[i]);
+ }
+ cubeIndicesVBO.seal(gl, true);
+ cubeIndicesVBO.enableBuffer(gl, false);
+ st.ownAttribute(cubeIndicesVBO, true);
+
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
@@ -322,7 +328,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrix.glTranslatef(0, 0, zoom0);
+ pmvMatrix.glTranslatef(0, 0, zoom);
}
@@ -362,7 +368,10 @@ public class TextureSequenceCubeES2 implements GLEventListener {
tex.bind(gl);
}
}
- gl.glDrawElements(GL.GL_TRIANGLES, 6 * 6, GL.GL_UNSIGNED_BYTE, cubeIndices);
+ cubeIndicesVBO.bindBuffer(gl, true); // keeps VBO binding
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, cubeIndicesVBO.getElementCount() * cubeIndicesVBO.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+ cubeIndicesVBO.bindBuffer(gl, false);
+
if(null != tex) {
tex.disable(gl);
}
@@ -444,7 +453,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
-1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f
};*/
- private static final byte[] s_cubeIndices =
+ private static final short[] s_cubeIndices =
{
0, 3, 1, 2, 0, 1, /* front */
6, 5, 4, 5, 7, 4, /* back */
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 b7c4e729e..ad096c7a6 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
@@ -204,6 +204,11 @@ public class MovieCube implements GLEventListener, GLMediaEventListener {
int height = 300;
System.err.println("TexCubeES2.run()");
+ boolean forceES2 = false;
+ boolean forceES3 = false;
+ boolean forceGL3 = false;
+ boolean forceGLDef = false;
+
String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
for(int i=0; i<args.length; i++) {
if(args[i].equals("-width")) {
@@ -215,13 +220,39 @@ public class MovieCube implements GLEventListener, GLMediaEventListener {
} else if(args[i].equals("-url")) {
i++;
url_s = args[i];
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ forceES3 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ } else if(args[i].equals("-gldef")) {
+ forceGLDef = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
}
}
+ System.err.println("forceES2 "+forceES2);
+ System.err.println("forceES3 "+forceES3);
+ System.err.println("forceGL3 "+forceGL3);
+ System.err.println("forceGLDef "+forceGLDef);
+
final MovieCube mc = new MovieCube(new URL(url_s).openConnection(), -2.3f, 0f, 0f);
- final GLWindow window = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2()));
+ final GLProfile glp;
+ if(forceGLDef) {
+ glp = GLProfile.getDefault();
+ } else if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+ System.err.println("GLProfile: "+glp);
+ final GLWindow window = GLWindow.create(new GLCapabilities(glp));
// Size OpenGL to Video Surface
window.setSize(width, height);
window.setFullscreen(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 e17c9e88b..5bf3145d0 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
@@ -140,8 +140,10 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
// prevMouseY = y;
}
public void mouseWheelMoved(MouseEvent e) {
- zoom += e.getWheelRotation()/10f;
- System.err.println("zoom: "+zoom);
+ if( !e.isShiftDown() ) {
+ zoom += e.getRotation()[1]/10f; // vertical: wheel
+ System.err.println("zoom: "+zoom);
+ }
}
};
@@ -198,8 +200,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
ShaderState st;
PMVMatrix pmvMatrix;
GLUniformData pmvMatrixUniform;
- 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";
@@ -209,20 +209,12 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
"../shader", "../shader/bin", shaderBasename, true);
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MovieSimple.class,
"../shader", "../shader/bin", shaderBasename, true);
+ rsVp.defaultShaderCustomization(gl, true, true);
+ int rsFpPos = rsFp.addGLSLVersion(gl);
- // 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, mPlayer.getRequiredExtensionsShaderStub());
- if(gl.isGLES2()) {
- rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
- }
+ rsFpPos = rsFp.addDefaultShaderPrecision(gl, rsFpPos);
+
final String texLookupFuncName = mPlayer.getTextureLookupFunctionName(myTextureLookupName);
rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
@@ -517,6 +509,11 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
boolean ortho = true;
boolean zoom = false;
+ boolean forceES2 = false;
+ boolean forceES3 = false;
+ boolean forceGL3 = false;
+ boolean forceGLDef = false;
+
String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
for(int i=0; i<args.length; i++) {
if(args[i].equals("-width")) {
@@ -525,6 +522,14 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
} else if(args[i].equals("-height")) {
i++;
height = MiscUtils.atoi(args[i], height);
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ forceES3 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ } else if(args[i].equals("-gldef")) {
+ forceGLDef = true;
} else if(args[i].equals("-projection")) {
ortho=false;
} else if(args[i].equals("-zoom")) {
@@ -534,12 +539,30 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
url_s = args[i];
}
}
+ 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.setScaleOrig(!zoom);
ms.setOrthoProjection(ortho);
try {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ final GLProfile glp;
+ if(forceGLDef) {
+ glp = GLProfile.getDefault();
+ } else if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+ System.err.println("GLProfile: "+glp);
+ GLCapabilities caps = new GLCapabilities(glp);
GLWindow window = GLWindow.create(caps);
window.addGLEventListener(ms);
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 3484ffa1d..e3be7b8b7 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
@@ -50,6 +50,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.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -103,7 +104,11 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
glJPanel.setMinimumSize(wsize);
glJPanel.setPreferredSize(wsize);
glJPanel.setSize(wsize);
- glJPanel.addGLEventListener(new GearsES2(swapInterval));
+ if( caps.isBitmap() ) {
+ glJPanel.addGLEventListener(new Gears(swapInterval));
+ } else {
+ 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
index 54dfe6726..4668603d8 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
@@ -40,6 +40,7 @@ import java.nio.FloatBuffer;
import javax.media.opengl.GLAnimatorControl;
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.GLJPanel;
import javax.swing.JComponent;
@@ -55,6 +56,7 @@ 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.jogl.demos.gl2.Gears;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -118,10 +120,16 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase {
if ( !useInterPanel ) {
canvas.setBounds(x, y, w, h);
}
- GearsES2 demo = new GearsES2(swapInterval);
- demo.setIgnoreFocus(true);
- demo.setGearsColors(color, color, color);
- demo.setClearColor(clearColor);
+ final GLEventListener demo;
+ if( caps.isBitmap() ) {
+ demo = new Gears(swapInterval);
+ } else {
+ GearsES2 gdemo = new GearsES2(swapInterval);
+ gdemo.setIgnoreFocus(true);
+ gdemo.setGearsColors(color, color, color);
+ gdemo.setClearColor(clearColor);
+ demo = gdemo;
+ }
canvas.addGLEventListener(demo);
if( null != anim ) {
anim.add(canvas);
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/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index a876b5c96..1a049c728 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
@@ -86,6 +86,7 @@ public class TestGearsES2NEWT extends UITestCase {
static int loops = 1;
static boolean loop_shutdown = false;
static boolean forceES2 = false;
+ static boolean forceES3 = false;
static boolean forceGL3 = false;
static boolean mainRun = false;
static boolean exclusiveContext = false;
@@ -358,6 +359,8 @@ public class TestGearsES2NEWT extends UITestCase {
final GLProfile glp;
if(forceGL3) {
glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
} else if(forceES2) {
glp = GLProfile.get(GLProfile.GLES2);
} else {
@@ -433,6 +436,8 @@ public class TestGearsES2NEWT extends UITestCase {
useAnimator = false;
} else if(args[i].equals("-es2")) {
forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ forceES3 = true;
} else if(args[i].equals("-gl3")) {
forceGL3 = true;
} else if(args[i].equals("-wait")) {
@@ -499,6 +504,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("forceES3 "+forceES3);
System.err.println("forceGL3 "+forceGL3);
System.err.println("swapInterval "+swapInterval);
System.err.println("exclusiveContext "+exclusiveContext);
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 eed2e1267..7a93faa1f 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
@@ -103,6 +103,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
Display display = null;
Shell shell = null;
Composite composite = null;
+ com.jogamp.newt.Display swtNewtDisplay = null;
@Before
public void init() {
@@ -120,6 +121,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
composite.setLayout( new FillLayout() );
Assert.assertNotNull( composite );
}});
+ swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
@After
@@ -142,6 +144,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ swtNewtDisplay = null;
display = null;
shell = null;
composite = null;
@@ -149,8 +152,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException {
System.err.println("requested: vsync "+swapInterval+", "+caps);
- com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null);
- com.jogamp.newt.Screen screen = NewtFactory.createScreen(dpy, screenIdx);
+ com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx);
final GLWindow glWindow = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/RedSquareShader.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/RedSquareShader.java
index cdbf3d9b8..07f3a97cb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/RedSquareShader.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/RedSquareShader.java
@@ -35,6 +35,11 @@ public class RedSquareShader {
" precision mediump int;\n" +
"#endif\n" +
"\n" +
+ "#if __VERSION__ >= 130\n" +
+ " #define attribute in\n" +
+ " #define varying out\n" +
+ "#endif\n"+
+ "\n" +
"uniform mat4 mgl_PMVMatrix[2];\n" +
"attribute vec4 mgl_Vertex;\n" +
"attribute vec4 mgl_Color;\n" +
@@ -52,10 +57,17 @@ public class RedSquareShader {
" precision mediump int;\n" +
"#endif\n" +
"\n" +
+ "#if __VERSION__ >= 130\n" +
+ " #define varying in\n" +
+ " out vec4 mgl_FragColor;\n" +
+ "#else\n" +
+ " #define mgl_FragColor gl_FragColor\n" +
+ "#endif\n" +
+ "\n" +
"varying vec4 frontColor;\n" +
"\n" +
"void main (void)\n" +
"{\n" +
- " gl_FragColor = frontColor;\n" +
+ " mgl_FragColor = frontColor;\n" +
"}\n" ;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.fp
index 1738d96d1..563e0a4b0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.fp
@@ -1,11 +1,16 @@
//Copyright 2010 JogAmp Community. All rights reserved.
-#version 110
+#if __VERSION__ >= 130
+ #define varying in
+ out vec4 mgl_FragData[2];
+#else
+ #define mgl_FragData gl_FragData
+#endif
varying vec4 frontColor;
void main (void)
{
- gl_FragData[0] = vec4( frontColor.r, 0.0, 0.0, 1.0 );
- gl_FragData[1] = vec4( 0.0, frontColor.g, 0.0, 1.0 );
+ mgl_FragData[0] = vec4( frontColor.r, 0.0, 0.0, 1.0 );
+ mgl_FragData[1] = vec4( 0.0, frontColor.g, 0.0, 1.0 );
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.vp
index 7f95a650a..4cab59c64 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-1.vp
@@ -1,6 +1,9 @@
// Copyright 2010 JogAmp Community. All rights reserved.
-#version 110
+#if __VERSION__ >= 130
+ #define attribute in
+ #define varying out
+#endif
uniform mat4 gcu_PMVMatrix[2]; // P, Mv, and Mvi
attribute vec4 gca_Vertices;
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 deac58ce1..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
@@ -1,6 +1,12 @@
//Copyright 2010 JogAmp Community. All rights reserved.
-#version 110
+#if __VERSION__ >= 130
+ #define varying in
+ out vec4 mgl_FragData[2];
+ #define texture2D texture
+#else
+ #define mgl_FragData gl_FragData
+#endif
uniform sampler2D gcs_TexUnit0;
uniform sampler2D gcs_TexUnit1;
@@ -12,5 +18,5 @@ void main (void)
{
vec2 rg = texture2D(gcs_TexUnit0, texCoord).rg + texture2D(gcs_TexUnit1, texCoord).rg;
float b = frontColor.b - length(rg);
- gl_FragData[0] = vec4( rg, b, 1.0 );
-} \ No newline at end of file
+ mgl_FragData[0] = vec4( rg, b, 1.0 );
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.vp
index 1b2c02328..89290b05a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.vp
@@ -1,6 +1,9 @@
//Copyright 2010 JogAmp Community. All rights reserved.
-#version 110
+#if __VERSION__ >= 130
+ #define attribute in
+ #define varying out
+#endif
uniform mat4 gcu_PMVMatrix[2]; // P, Mv, and Mvi
attribute vec4 gca_Vertices;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsequence_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsequence_xxx.fp
index 5e7bd2879..e4f21f95f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsequence_xxx.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsequence_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/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp
index c213f3ab4..93f252cd6 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
@@ -19,10 +19,10 @@ void main (void)
if(0.0 <= mgl_texCoord.t && mgl_texCoord.t<=1.0) {
texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
} else {
- texColor = vec4(1, 1, 1, 1);
+ discard;
}
- // mix frontColor with texture ..
- mgl_FragColor = vec4(frontColor*texColor);
+ // mix frontColor with texture .. pre-multiplying texture alpha
+ mgl_FragColor = vec4( mix( frontColor.rgb, texColor.rgb, texColor.a ), frontColor.a );
}
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 fbcfb26f3..020c5c63f 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
@@ -1,9 +1,7 @@
package com.jogamp.opengl.test.junit.jogl.demos.gl2;
-import javax.media.opengl.GL;
import javax.media.opengl.GL2;
-import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -18,6 +16,7 @@ import com.jogamp.newt.event.MouseEvent;
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;
/**
* Gears.java <BR>
@@ -72,14 +71,7 @@ public class Gears implements GLEventListener {
System.err.println("GearsGL2 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());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
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/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;
}
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 0f9c50baa..f8fbe7276 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
@@ -52,6 +52,7 @@ import javax.media.opengl.GLProfile;
import junit.framework.Assert;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow ;
@@ -226,6 +227,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
{
try {
System.err.println("[K-"+_n+"]");
+ AWTRobotUtil.waitForIdle(_robot);
AWTRobotUtil.newtKeyPress(_n, _robot, true, KeyEvent.VK_0, 10);
AWTRobotUtil.newtKeyPress(_n, _robot, false, KeyEvent.VK_0, 0);
Thread.sleep( 40L ) ;
@@ -249,6 +251,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
volatile Display display;
volatile Shell shell;
volatile Composite composite;
+ volatile com.jogamp.newt.Display swtNewtDisplay = null;
public void init() {
SWTAccessor.invoke(true, new Runnable() {
@@ -265,7 +268,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
composite = new Composite( shell, SWT.NO_BACKGROUND );
composite.setLayout( new FillLayout() );
Assert.assertNotNull( composite );
- }});
+ }});
+ swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
public void dispose() {
@@ -287,6 +291,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ swtNewtDisplay = null;
display = null;
shell = null;
composite = null;
@@ -304,7 +309,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
{
final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ;
final GLCapabilities caps = new GLCapabilities( gl2Profile ) ;
- glWindow = GLWindow.create( caps ) ;
+ com.jogamp.newt.Screen screen = NewtFactory.createScreen(dsc.swtNewtDisplay, 0);
+ glWindow = GLWindow.create( screen, caps ) ;
glWindow.addGLEventListener( new BigFlashingX() ) ;
glWindow.addKeyListener(new KeyAdapter() {
@Override
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 396d219b4..7acc6452e 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
@@ -48,6 +48,8 @@ import org.junit.After;
import org.junit.Test;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -81,7 +83,8 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
Display display = null;
Shell shell = null;
Composite composite = null;
-
+ com.jogamp.newt.Display swtNewtDisplay = null;
+
@BeforeClass
public static void startup() {
System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
@@ -103,6 +106,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
composite.setLayout( new FillLayout() );
Assert.assertNotNull( composite );
}});
+ swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
@After
@@ -125,6 +129,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ swtNewtDisplay = null;
display = null;
shell = null;
composite = null;
@@ -134,7 +139,8 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
boolean postAttach, boolean useAnimator ) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
- final GLWindow glWindow1 = GLWindow.create(caps);
+ final Screen screen = NewtFactory.createScreen(swtNewtDisplay, 0);
+ final GLWindow glWindow1 = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow1);
Assert.assertEquals(false, glWindow1.isVisible());
Assert.assertEquals(false, glWindow1.isNativeValid());
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() {
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 66911ef06..4d279b349 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
@@ -49,6 +49,7 @@ import jogamp.newt.swt.event.SWTNewtEventFactory;
import junit.framework.Assert;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.opengl.GLWindow ;
import com.jogamp.newt.swt.NewtCanvasSWT ;
import com.jogamp.opengl.swt.GLCanvas;
@@ -140,7 +141,9 @@ public class TestSWTBug643AsyncExec extends UITestCase {
{
try
{
- swtDisplay.asyncExec( swtAsyncAction );
+ if( !swtDisplay.isDisposed() ) {
+ 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);
@@ -227,9 +230,10 @@ public class TestSWTBug643AsyncExec extends UITestCase {
glad = glc;
newtDisplay = null;
} else if( useNewtCanvasSWT ) {
- final GLWindow glWindow = GLWindow.create( caps ) ;
+ newtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
+ com.jogamp.newt.Screen screen = NewtFactory.createScreen(newtDisplay, 0);
+ final GLWindow glWindow = GLWindow.create( screen, 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);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
index b38ae85e8..02f161cf6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
@@ -62,9 +62,6 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
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();
@@ -76,19 +73,8 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
"../demos/es2/shader", "../demos/es2/shader/bin", "mgl_default_xxx", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, DemoGL2ES2ImmModeSink.class,
"../demos/es2/shader", "../demos/es2/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]);
- }
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
sp = new ShaderProgram();
sp.add(gl, vp0, System.err);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java
index 48f1df757..165a3b8cf 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java
@@ -81,15 +81,13 @@ public class TestImmModeSinkES2NEWT extends UITestCase {
@Test
public void test05ImmSinkGL2ES2_VBOOff_Direct() throws InterruptedException {
- final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
- if(null == reqGLCaps) return;
+ final GLCapabilities reqGLCaps = new GLCapabilities( GLProfile.getMaxFixedFunc(true) );
doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, false));
}
@Test
public void test05ImmSinkGL2ES2_VBOOff_ShaderState() throws InterruptedException {
- final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
- if(null == reqGLCaps) return;
+ final GLCapabilities reqGLCaps = new GLCapabilities( GLProfile.getMaxFixedFunc(true) );
doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, true));
}
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 bf8323e88..5181dc2d3 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
@@ -1,3 +1,30 @@
+/**
+ * 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.util.texture;
import java.io.IOException;
@@ -28,24 +55,36 @@ import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.spi.JPEGImage;
import javax.media.opengl.GL;
+/**
+ * Test reading and displaying a JPG image.
+ * <p>
+ * Main function accepts arbitrary JPG file name for manual tests.
+ * </p>
+ */
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 {
+ public void testImpl(final InputStream istream) throws InterruptedException, IOException {
+ final JPEGImage image = JPEGImage.read(istream);
+ Assert.assertNotNull(image);
+ final boolean hasAlpha = 4 == image.getBytesPerPixel();
+ System.err.println("JPEGImage: "+image+", hasAlpha "+hasAlpha);
+
final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
- if( withAlpha ) {
+ if( hasAlpha ) {
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 int internalFormat;
+ if(glp.isGL2GL3()) {
+ 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(),
@@ -102,10 +141,10 @@ public class TestJPEGImage01NEWT extends UITestCase {
}
@Test
- public void testReadES2_RGB() throws InterruptedException, IOException, MalformedURLException {
+ public void testReadES2_RGBn() throws InterruptedException, IOException, MalformedURLException {
final String fname = null == _fname ? "test-ntscN_3-01-160x90-90pct-yuv444-base.jpg" : _fname;
final URLConnection urlConn = IOUtil.getResource(this.getClass(), fname);
- testImpl(false, urlConn.getInputStream());
+ testImpl(urlConn.getInputStream());
}
static String _fname = 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 82867f9e6..adce6245e 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
@@ -160,8 +160,8 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase {
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();
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2)) {
+ glp = GLProfile.getMaxFixedFunc(true);
} else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
glp = GLProfile.getGL2ES2();
} else {
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..aedb6a573
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java
@@ -0,0 +1,89 @@
+/**
+ * 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 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
index 81f64f0ae..839a198b9 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
@@ -1,62 +1,179 @@
+/**
+ * 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.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 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.
+ * <p>
+ * Main function accepts arbitrary PNG file name for manual tests.
+ * </p>
+ */
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());
- }
+
+ 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 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());
+ final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ if( hasAlpha ) {
+ caps.setAlphaBits(1);
}
- // 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);
+ final int internalFormat;
+ if(glp.isGL2GL3()) {
+ 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);
- // 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);
+ // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG);
+ System.err.println("TextureData: "+texData);
- // 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);
+ 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 ) ;
+ // 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()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glad.destroy();
}
+ @Test
+ public void testRead01_RGBn_exp() throws InterruptedException, IOException, MalformedURLException {
+ final String fname = null == _fname ? "bug724-transparent-grey_gimpexp.png" : _fname;
+ final URLConnection urlConn = IOUtil.getResource(this.getClass(), fname);
+ testImpl(urlConn.getInputStream());
+ }
+
+ @Test
+ public void testRead02_RGBn_orig() throws InterruptedException, IOException, MalformedURLException {
+ if( null != _fname ) {
+ return;
+ }
+ final String fname = "bug724-transparent-grey_orig.png";
+ final URLConnection urlConn = IOUtil.getResource(this.getClass(), fname);
+ testImpl(urlConn.getInputStream());
+ }
+
+ static String _fname = null;
public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-file")) {
+ i++;
+ _fname = args[i];
+ }
+ }
org.junit.runner.JUnitCore.main(TestPNGImage01NEWT.class.getName());
}
}
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 651eeb5f9..756a8d8e4 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
@@ -102,8 +102,8 @@ public class TestPNGTextureFromFileAWT extends UITestCase {
{
final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
GLProfile glp;
- if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) {
- glp = GLProfile.getGL2GL3();
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2)) {
+ glp = GLProfile.getMaxFixedFunc(true);
} else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
glp = GLProfile.getGL2ES2();
} else {
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 773b839a2..42e5230da 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
@@ -150,8 +150,8 @@ public class TestPNGTextureFromFileNEWT extends UITestCase {
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();
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2)) {
+ glp = GLProfile.getMaxFixedFunc(true);
} else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
glp = GLProfile.getGL2ES2();
} else {
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 c33384611..6913cf30e 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
@@ -80,7 +80,7 @@ public class TestTexture01AWT extends UITestCase {
UITestCase.setTestSupported(false);
return;
}
- glp = GLProfile.getGL2GL3();
+ glp = GLProfile.getMaxFixedFunc(true);
Assert.assertNotNull(glp);
caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_gimpexp.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_gimpexp.png
new file mode 100644
index 000000000..53b2ec07b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_gimpexp.png
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_orig.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_orig.png
new file mode 100644
index 000000000..b85bf7e15
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug724-transparent-grey_orig.png
Binary files differ
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
index e4867e3fe..6a248bcf6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
@@ -37,6 +37,8 @@ import javax.media.opengl.*;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
+import com.jogamp.newt.util.EDTUtil;
+
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -89,7 +91,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
+ Assert.assertEquals(false,display.getEDTUtil().isRunning());
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
@@ -199,10 +201,17 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(false,display.getEDTUtil().isRunning());
- display.getEDTUtil().invoke(true, null);
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
+ {
+ final EDTUtil edtUtil = display.getEDTUtil();
+ Assert.assertNotNull(edtUtil);
+ Assert.assertEquals(false,edtUtil.isRunning());
+ edtUtil.restart();
+ edtUtil.invoke(true, null);
+ Assert.assertEquals(true,edtUtil.isRunning());
+ edtUtil.invokeStop(true, null);
+ edtUtil.waitUntilStopped();
+ Assert.assertEquals(false,edtUtil.isRunning());
+ }
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
index bf509124b..3ab81bd2f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
@@ -39,6 +39,7 @@ import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
import java.io.IOException;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -141,6 +142,9 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
// destruction.. ref count down, but keep all
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
@@ -186,6 +190,9 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
System.err.println("duration: "+window.getTotalFPSDuration());
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -208,7 +215,9 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(0,Display.getActiveDisplayNumber());
// Create Display/Screen, pending lazy native creation
+ System.err.println("Pass - 1");
testDisplayCreate01Impl();
+ System.err.println("Pass - 2");
testDisplayCreate01Impl();
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -285,6 +294,8 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
// destruction ...
window1.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window1, false));
+
Assert.assertNotNull(window1.getScreen());
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
@@ -300,6 +311,9 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
// destruction
window2.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+
Assert.assertNotNull(window2.getScreen());
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
@@ -314,12 +328,12 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
- // invalidate .. remove all refs
+ // invalidate (again) ..
window1.destroy();
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
- // invalidate .. remove all refs
+ // invalidate (again) ..
window2.destroy();
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
@@ -331,7 +345,9 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(0,Display.getActiveDisplayNumber());
// Create Display/Screen, pending lazy native creation
+ System.err.println("Pass - 1");
testDisplayCreate02Impl();
+ System.err.println("Pass - 2");
testDisplayCreate02Impl();
Assert.assertEquals(0,Display.getActiveDisplayNumber());
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..5b07c73bd 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());
@@ -204,9 +202,14 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
System.err.println("FOCUS NEWT Canvas/GLWindow request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA);
- Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+ // 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, 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());
@@ -221,9 +224,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
System.err.println("FOCUS AWT Button request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthInner, buttonNorthInner, buttonNorthInnerFA, glWindow1FA);
+ Assert.assertEquals(false, glWindow1FA.focusGained());
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 +239,15 @@ 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());
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
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..a959a56be 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 ;
/**
@@ -385,7 +386,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
// run the tests for NewtCanvasAWT and NewtCanvasSWT until we can
// pay more attention to the NEWT event modifier stuff.
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonPressAndRelease() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -395,7 +396,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} } );
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonPressAndReleaseWithShift() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -405,7 +406,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} } );
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonPressAndReleaseWithCtrl() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -418,7 +419,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
/**
* 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
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonPressAndReleaseWithMeta() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -428,7 +429,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} } );
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonPressAndReleaseWithAlt() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -458,7 +459,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
////////////////////////////////////////////////////////////////////////////
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testHoldOneButtonAndPressAnother() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -468,7 +469,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} } );
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testPressAllButtonsInSequence() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -478,7 +479,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} } );
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void testSingleButtonClickAndDrag() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
@@ -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/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java
index a847ca671..1504c948e 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
@@ -85,7 +85,9 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers {
public static void afterClass() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- _testFrame.dispose() ;
+ if( null != _testFrame ) {
+ _testFrame.dispose() ;
+ }
}
}) ;
}
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 968d1af79..e0bc847a7 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
@@ -98,7 +98,9 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers
public static void afterClass() throws Exception {
SwingUtilities.invokeAndWait( new Runnable() {
public void run() {
- _testFrame.dispose() ;
+ if( null != _testFrame ) {
+ _testFrame.dispose() ;
+ }
}
} ) ;
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 cc32d5331..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,20 +139,26 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie
eventDispatchImpl();
_glWindow.addMouseListener( _testMouseListener ) ;
+ */
}
////////////////////////////////////////////////////////////////////////////
@AfterClass
public static void afterClass() throws Exception {
+ /**
_glWindow.destroy() ;
try {
SWTAccessor.invoke(_display, true, new Runnable() {
public void run() {
- _composite.dispose();
- _shell.dispose();
- if(!_display.isDisposed()) {
+ if( null != _composite ) {
+ _composite.dispose();
+ }
+ if( null != _shell ) {
+ _shell.dispose();
+ }
+ if( null != _display && !_display.isDisposed()) {
_display.dispose();
}
}});
@@ -156,7 +166,7 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie
catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ } */
}
////////////////////////////////////////////////////////////////////////////
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 c1b572df3..0f79d9b9c 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
@@ -95,7 +95,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
public void releaseTest() {
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
glWindow.setSize(width, height);
@@ -141,7 +141,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
glWindow.destroy();
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException {
if( JAWTUtil.isOffscreenLayerRequired() ) {
System.err.println("Platform doesn't support onscreen rendering.");
@@ -150,7 +150,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
testNewtCanvasAWT_Impl(true);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException {
if( !JAWTUtil.isOffscreenLayerSupported() ) {
System.err.println("Platform doesn't support offscreen rendering.");
@@ -162,18 +162,20 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode,
char keyCharOnly, char keyCharMod) {
keyAdapter.reset();
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode
AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release keyCode
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2; j++) { // wait until events are collected
robot.delay(100);
}
+ AWTRobotUtil.waitForIdle(robot);
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 keyCode
AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2+4; j++) { // wait until events are collected
robot.delay(100);
}
@@ -202,6 +204,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
final int m3m = InputEvent.SHIFT_MASK;
keyAdapter.reset();
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.newtKeyPress(0, robot, true, m1k, 10); // press MOD1
AWTRobotUtil.newtKeyPress(0, robot, true, m2k, 10); // press MOD2
AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3
@@ -210,9 +213,9 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
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
+ AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD
+ AWTRobotUtil.waitForIdle(robot);
- robot.waitForIdle();
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4; j++) { // wait until events are collected
robot.delay(100);
}
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 a5f47e870..333a21b89 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
@@ -91,7 +91,7 @@ public class TestNewtKeyCodesAWT extends UITestCase {
public void releaseTest() {
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
glWindow.setSize(width, height);
@@ -137,7 +137,7 @@ public class TestNewtKeyCodesAWT extends UITestCase {
glWindow.destroy();
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException {
if( JAWTUtil.isOffscreenLayerRequired() ) {
System.err.println("Platform doesn't support onscreen rendering.");
@@ -146,7 +146,7 @@ public class TestNewtKeyCodesAWT extends UITestCase {
testNewtCanvasAWT_Impl(true);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException {
if( !JAWTUtil.isOffscreenLayerSupported() ) {
System.err.println("Platform doesn't support offscreen rendering.");
@@ -195,6 +195,7 @@ public class TestNewtKeyCodesAWT extends UITestCase {
// System.err.println("*** Segment "+codeSeg.description);
int eventCount = 0;
for(short c=codeSeg.min; c<=codeSeg.max; c++) {
+ AWTRobotUtil.waitForIdle(robot);
// System.err.println("*** KeyCode 0x"+Integer.toHexString(c));
try {
AWTRobotUtil.newtKeyPress(0, robot, true, c, 10);
@@ -210,8 +211,8 @@ public class TestNewtKeyCodesAWT extends UITestCase {
break;
}
eventCount++;
- robot.waitForIdle();
}
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected
robot.delay(100);
}
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 b6c15231c..8b8a5ac79 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
@@ -108,7 +108,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
public void releaseTest() {
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
glWindow.setSize(width, height);
@@ -119,7 +119,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
glWindow.destroy();
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
@@ -161,10 +161,10 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
int firstIdx = 0;
for(int i=0; i<loops; i++) {
System.err.println("+++ KEY Event Auto-Repeat START Input Loop: "+i);
+ AWTRobotUtil.waitForIdle(robot);
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, 500); // 1s .. no AR anymore
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
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
@@ -182,10 +182,10 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
// 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);
- robot.waitForIdle();
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 20 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected
robot.delay(100);
}
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 3a95eacae..d0c3813d5 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
@@ -94,7 +94,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
public void releaseTest() {
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
glWindow.setSize(width, height);
@@ -140,7 +140,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
glWindow.destroy();
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException {
if( JAWTUtil.isOffscreenLayerRequired() ) {
System.err.println("Platform doesn't support onscreen rendering.");
@@ -149,7 +149,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
testNewtCanvasAWT_Impl(true);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException {
if( !JAWTUtil.isOffscreenLayerSupported() ) {
System.err.println("Platform doesn't support offscreen rendering.");
@@ -163,26 +163,27 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
keyAdapter.reset();
for(int i=0; i<loops; i++) {
// 1
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 100);
- robot.waitForIdle();
// 2
+ 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, 100);
- robot.waitForIdle();
// 3 + 4
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 10);
- robot.waitForIdle();
// 5 + 6
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 10);
- robot.waitForIdle();
}
+ AWTRobotUtil.waitForIdle(robot);
robot.delay(250);
// dumpKeyEvents(keyAdapter.getQueued());
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 d70259f13..e0d2ae2ee 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
@@ -89,7 +89,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase {
public void releaseTest() {
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException {
GLWindow glWindow = GLWindow.create(glCaps);
glWindow.setSize(width, height);
@@ -135,7 +135,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase {
glWindow.destroy();
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException {
if( JAWTUtil.isOffscreenLayerRequired() ) {
System.err.println("Platform doesn't support onscreen rendering.");
@@ -144,7 +144,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase {
testNewtCanvasAWT_Impl(true);
}
- @Test
+ @Test(timeout=180000) // TO 3 min
public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException {
if( !JAWTUtil.isOffscreenLayerSupported() ) {
System.err.println("Platform doesn't support offscreen rendering.");
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java
index 875e4fe86..464efa5bb 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.opengl.GLCapabilities;
@@ -51,7 +51,7 @@ import javax.media.nativewindow.util.Dimension;
* which shall reset the ScreenMode to it's original state
* when the application exists (normal or ctrl-c).
*/
-public class ManualScreenMode03NEWT extends UITestCase {
+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) {
@@ -108,7 +108,7 @@ public class ManualScreenMode03NEWT extends UITestCase {
}
public static void main(String args[]) throws IOException {
- ManualScreenMode03NEWT t = new ManualScreenMode03NEWT();
+ ManualScreenMode03aNEWT t = new ManualScreenMode03aNEWT();
t.run();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
index f64cf2eb8..151cc0a56 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.nativewindow.NativeWindowFactory;
@@ -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;
@@ -53,7 +55,14 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.MonitorDeviceImpl;
import jogamp.newt.MonitorModeProps;
-public class TestScreenMode00NEWT extends UITestCase {
+/**
+ * Validating consistency of MonitorMode data from Screen (all modes)
+ * and from a particular MonitorDevice.
+ * <p>
+ * Also validates the descending order of the given MonitorMode lists.
+ * </p>
+ */
+public class TestScreenMode00aNEWT extends UITestCase {
static int screenIdx = 0;
static int width, height;
@@ -64,6 +73,7 @@ public class TestScreenMode00NEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi)
NativeWindowFactory.initSingleton();
width = 640;
@@ -126,8 +136,27 @@ public class TestScreenMode00NEWT extends UITestCase {
Assert.assertTrue(allMonitorModes.size()>0);
{
int i=0;
+ MonitorMode mmPre = null;
+ for(Iterator<MonitorMode> 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<MonitorMode> 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;
}
}
@@ -140,8 +169,14 @@ public class TestScreenMode00NEWT extends UITestCase {
List<MonitorMode> modes = monitor.getSupportedModes();
Assert.assertTrue(modes.size()>0);
int i=0;
+ MonitorMode mmPre = null;
for(Iterator<MonitorMode> 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));
@@ -173,7 +208,7 @@ public class TestScreenMode00NEWT extends UITestCase {
screenIdx = atoi(args[i]);
}
}
- String tstname = TestScreenMode00NEWT.class.getName();
+ String tstname = TestScreenMode00aNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00bNEWT.java
index fe5dd93cb..d5323e1d2 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00bNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.nativewindow.NativeWindowFactory;
@@ -51,6 +51,10 @@ import java.util.List;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
+/**
+ * Queries the current MonitorMode 50 times,
+ * stressing a possible race condition.
+ */
public class TestScreenMode00bNEWT extends UITestCase {
static int width, height;
@@ -59,6 +63,7 @@ public class TestScreenMode00bNEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
NativeWindowFactory.initSingleton();
width = 640;
height = 480;
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..bc1dcf792
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java
@@ -0,0 +1,244 @@
+/**
+ * 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 boolean manualTest = false;
+ static GLProfile glp;
+ static int width, height;
+
+ static final int waitTimeShort = 2000;
+ static long duration = waitTimeShort;
+
+ @BeforeClass
+ public static void initClass() {
+ setResetXRandRIfX11AfterClass();
+ NativeWindowFactory.initSingleton();
+ if( !manualTest || 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<MonitorMode> 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<MonitorMode> 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());
+
+ // WARNING: See note in 'UITestCase.resetXRandRIfX11();'
+ UITestCase.resetXRandRIfX11();
+ System.err.println("XRandR Reset :"+monitor.queryCurrentMode());
+ validateScreenModeReset0(mmOrig);
+
+ destroyWindow(window0);
+
+ Thread.sleep(waitTimeShort);
+ validateScreenModeReset(mmOrig);
+ }
+
+ 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
+ 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();
+ }
+ 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 {
+ manualTest = true;
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ String tstname = TestScreenMode00cNEWT.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/mm/TestScreenMode01aNEWT.java
index c638058f4..bff220648 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.opengl.GLCapabilities;
@@ -46,15 +46,22 @@ 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;
/**
+ * <p>
+ * Tests MonitorMode reset, by destroying the last Screen (reference),
+ * i.e. the original MonitorMode should get reinstated!
+ * </p>
+ * <p>
* Documents remedy B) for NV RANDR/GL bug
+ * </p>
*
- * @see TestScreenMode01NEWT#cleanupGL()
+ * @see TestScreenMode01dNEWT#cleanupGL()
*/
public class TestScreenMode01aNEWT extends UITestCase {
static GLProfile glp;
@@ -65,6 +72,7 @@ public class TestScreenMode01aNEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
width = 100;
height = 100;
glp = GLProfile.getDefault();
@@ -89,9 +97,10 @@ public class TestScreenMode01aNEWT extends UITestCase {
return window;
}
- static void destroyWindow(Window window) {
+ static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
@@ -99,16 +108,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<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ final List<MonitorMode> allMonitorModes = screen.getMonitorModes();
Assert.assertTrue(allMonitorModes.size()>0);
if(allMonitorModes.size()==1) {
// no support ..
@@ -117,7 +126,7 @@ public class TestScreenMode01aNEWT extends UITestCase {
return;
}
- MonitorDevice monitor = window0.getMainMonitor();
+ final MonitorDevice monitor = screen.getMonitorDevices().get(0);
List<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
@@ -129,13 +138,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
@@ -155,54 +164,58 @@ 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);
- // 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.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/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
index 9108853e5..3c363b3f5 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.opengl.GLCapabilities;
@@ -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;
@@ -66,6 +67,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
width = 200;
height = 200;
glp = GLProfile.getDefault();
@@ -92,9 +94,10 @@ public class TestScreenMode01bNEWT extends UITestCase {
return window;
}
- static void destroyWindow(Window window) {
+ static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
@@ -110,6 +113,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY());
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
@@ -129,6 +133,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY());
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
@@ -196,15 +201,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());
@@ -217,11 +226,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());
@@ -230,6 +244,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
Thread.sleep(duration);
anim.stop();
destroyWindow(window0);
+
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/TestScreenMode01cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java
index 30c06e932..6a7a399ee 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.opengl.GLCapabilities;
@@ -45,6 +45,7 @@ import com.jogamp.newt.Window;
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.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
@@ -55,7 +56,7 @@ import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
/**
- * Fullscreen on separate monitors ..
+ * Fullscreen on separate monitors, incl. spanning across multiple monitors.
*/
public class TestScreenMode01cNEWT extends UITestCase {
static GLProfile glp;
@@ -66,6 +67,7 @@ public class TestScreenMode01cNEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
width = 200;
height = 200;
glp = GLProfile.getDefault();
@@ -92,9 +94,10 @@ public class TestScreenMode01cNEWT extends UITestCase {
return window;
}
- static void destroyWindow(Window window) {
+ static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
@@ -110,6 +113,7 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
@@ -129,6 +133,7 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
@@ -152,6 +157,7 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors);
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
@@ -171,6 +177,7 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null);
} finally {
screen.removeReference();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
index a2ce7cec0..b4fd132a7 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
import javax.media.opengl.GLCapabilities;
@@ -53,14 +53,20 @@ 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 with and without ScreenMode change.
- *
+ * Demonstrates fullscreen without MonitorMode change
+ * and fullscreen before and after MonitorMode change.
+ * <p>
+ * Also tests MonitorMode reset, by destroying the last Screen (reference),
+ * i.e. the original MonitorMode should get reinstated!
+ * </p>
* <p>
- * Also documents NV RANDR/GL bug, see {@link TestScreenMode01NEWT#cleanupGL()}.</p>
+ * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p>
*/
-public class TestScreenMode01NEWT extends UITestCase {
+public class TestScreenMode01dNEWT extends UITestCase {
static GLProfile glp;
static int width, height;
@@ -69,6 +75,7 @@ public class TestScreenMode01NEWT extends UITestCase {
@BeforeClass
public static void initClass() {
+ setResetXRandRIfX11AfterClass();
width = 640;
height = 480;
glp = GLProfile.getDefault();
@@ -130,14 +137,15 @@ public class TestScreenMode01NEWT extends UITestCase {
return window;
}
- static void destroyWindow(Window window) {
+ static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
@Test
- public void testFullscreenChange01() throws InterruptedException {
+ public void test01FullscreenChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
@@ -175,15 +183,19 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(false, animator.isStarted());
destroyWindow(window);
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
- Assert.assertEquals(false, window.isRealized());
- Assert.assertEquals(false, window.isNativeValid());
+
+ 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());
cleanupGL();
}
@Test
- public void testScreenModeChange01() throws InterruptedException {
+ public void test02ScreenModeChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
GLCapabilities caps = new GLCapabilities(glp);
@@ -195,7 +207,8 @@ public class TestScreenMode01NEWT 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<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
@@ -234,18 +247,22 @@ public class TestScreenMode01NEWT 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);
- // check reset ..
-
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
@@ -256,7 +273,6 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(false, animator.isStarted());
destroyWindow(window);
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isRealized());
@@ -265,33 +281,20 @@ public class TestScreenMode01NEWT 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 +305,8 @@ public class TestScreenMode01NEWT 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();
@@ -334,9 +338,20 @@ public class TestScreenMode01NEWT extends UITestCase {
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);
+ Thread.sleep(waitTimeShort);
+
+ // 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());
@@ -347,8 +362,14 @@ public class TestScreenMode01NEWT 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());
@@ -359,7 +380,6 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(false, animator.isStarted());
destroyWindow(window);
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isRealized());
@@ -368,25 +388,31 @@ public class TestScreenMode01NEWT 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 = TestScreenMode01NEWT.class.getName();
+ 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..25751662d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java
@@ -0,0 +1,250 @@
+/**
+ * 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.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,
+ * w/ and w/o fullscreen, pre and post MonitorMode change.
+ * <p>
+ * MonitorMode change does not use highest resolution.
+ * </p>
+ */
+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() {
+ setResetXRandRIfX11AfterClass();
+ width = 640;
+ height = 480;
+ glp = GLProfile.getDefault();
+ }
+
+ 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(1));
+ Assert.assertNotNull(window);
+ return window;
+ }
+
+ static void destroyWindow(Window window) throws InterruptedException {
+ if(null!=window) {
+ window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ }
+ }
+
+ @Test
+ 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
+ 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);
+ if( preVis ) {
+ window.setVisible(true);
+ if( fullscreen ) {
+ window.setFullscreen(true);
+ }
+ } else {
+ screen.createNative();
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
+ }
+
+ Animator animator = new Animator(window);
+ animator.start();
+
+ final MonitorDevice monitor = window.getMainMonitor();
+ final MonitorMode mmOrig = monitor.getOriginalMode();
+ Assert.assertNotNull(mmOrig);
+ if(changeMode) {
+ Thread.sleep(waitTimeShort);
+
+ List<MonitorMode> monitorModes = monitor.getSupportedModes();
+ if(monitorModes.size()==1) {
+ // no support ..
+ System.err.println("Your platform has no ScreenMode change support, sorry");
+ animator.stop();
+ destroyWindow(window);
+ return;
+ }
+ Assert.assertTrue(monitorModes.size()>0);
+
+ 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");
+ animator.stop();
+ 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);
+
+ // 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 ) {
+ if( fullscreen ) {
+ window.setFullscreen(true);
+ }
+ window.setVisible(true);
+ }
+
+ Thread.sleep(waitTimeLong);
+
+ if( !preVis && fullscreen ) {
+ window.setFullscreen(false);
+ }
+
+ if(changeMode) {
+ Thread.sleep(waitTimeShort);
+
+ // manual restore!
+ {
+ 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);
+ }
+
+ if( preVis && fullscreen ) {
+ window.setFullscreen(false);
+ }
+
+ 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());
+ }
+
+ 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/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java
index 58bce4cc9..aa1bbad3f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java
@@ -26,14 +26,12 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt;
+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;
@@ -51,20 +49,36 @@ 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 com.jogamp.opengl.util.Animator;
+
import java.util.List;
import javax.media.nativewindow.util.Dimension;
-public class TestScreenMode02NEWT extends UITestCase {
+/**
+ * Tests MonitorMode change w/ changed rotation and fullscreen.
+ * <p>
+ * MonitorMode change uses highest resolution.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * Documents remedy B) for NV RANDR/GL bug
+ * </p>
+ *
+ * @see TestScreenMode01NEWT#cleanupGL()
+ */
+public class TestScreenMode02bNEWT 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;
+ setResetXRandRIfX11AfterClass();
glp = GLProfile.getDefault();
}
@@ -73,59 +87,86 @@ public class TestScreenMode02NEWT extends UITestCase {
Thread.sleep(waitTimeShort);
}
- static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) {
Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
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());
+ window.addGLEventListener(new GearsES2(1));
Assert.assertNotNull(window);
- window.setVisible(true);
- Assert.assertTrue(window.isVisible());
return window;
}
- static void destroyWindow(Window window) {
+ static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
@Test
- public void testScreenRotationChange01() throws InterruptedException {
- Thread.sleep(waitTimeShort);
-
+ 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);
- GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window);
+ 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<MonitorMode> 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();
+ MonitorDevice monitor = window.getMainMonitor();
List<MonitorMode> 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 (monitor), sorry");
destroyWindow(window);
return;
}
- Assert.assertTrue(monitorModes.size()>0);
-
+ Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
+
Animator animator = new Animator(window);
animator.start();
-
- MonitorMode mmCurrent = monitor.getCurrentMode();
+
+ MonitorMode mmCurrent = monitor.queryCurrentMode();
Assert.assertNotNull(mmCurrent);
- MonitorMode mmOrig = monitor.getOriginalMode();
+ 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);
@@ -133,65 +174,85 @@ public class TestScreenMode02NEWT extends UITestCase {
if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) {
// no rotation support ..
System.err.println("Your platform has no rotation support, sorry");
+ animator.stop();
destroyWindow(window);
return;
}
- monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601));
+ 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.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());
+ // 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);
+ if( !smOk ) {
+ System.err.println("ERROR: Full MonitorMode w/ rotation failure - Expected on some platforms (NV driver) - Tolerated for now.");
+ animator.stop();
+ destroyWindow(window);
+ return;
+ }
+ 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);
+ window.setVisible(true);
+ }
+
Thread.sleep(waitTimeLong);
+
+ if( !preVis ) {
+ window.setFullscreen(false);
+ }
+
+ // 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);
+ }
+ Thread.sleep(waitTimeShort);
- // check reset ..
-
+ if( preVis ) {
+ window.setFullscreen(false);
+ }
+
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- animator.stop();
+ 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();
+ String tstname = TestScreenMode02bNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
-
}
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..d618d3b3c 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
@@ -74,7 +74,7 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
+ Assert.assertEquals(false,display.getEDTUtil().isRunning());
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -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<args.length; i++) {
if(args[i].equals("-time")) {
durationPerTest = atoi(args[++i]);
+ } else if(args[i].equals("-asMain")) {
+ asMain = true;
}
}
System.err.println("durationPerTest: "+durationPerTest);
- String tstname = TestParenting01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
+ if( asMain ) {
+ try {
+ TestParenting01NEWT.initClass();
+ TestParenting01NEWT m = new TestParenting01NEWT();
+ m.testWindowParenting02ReparentTop2WinReparentRecreate();
+ m.testWindowParenting01CreateVisibleDestroy();
+ } catch (Throwable t ) {
+ t.printStackTrace();
+ }
+ } else {
+ String tstname = TestParenting01NEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}
}
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
index 11aef7c24..c95ac1985 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java
@@ -47,6 +47,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Window;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
@@ -65,6 +66,7 @@ public class TestParenting01aSWT extends UITestCase {
Display display = null;
Shell shell = null;
Composite composite1 = null;
+ com.jogamp.newt.Display swtNewtDisplay = null;
@BeforeClass
public static void initClass() {
@@ -86,6 +88,7 @@ public class TestParenting01aSWT extends UITestCase {
composite1.setLayout( new FillLayout() );
Assert.assertNotNull( composite1 );
}});
+ swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
@After
@@ -105,6 +108,7 @@ public class TestParenting01aSWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ swtNewtDisplay = null;
display = null;
shell = null;
composite1 = null;
@@ -113,7 +117,8 @@ public class TestParenting01aSWT extends UITestCase {
@Test
public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException {
- GLWindow glWindow1 = GLWindow.create(glCaps);
+ com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, 0);
+ GLWindow glWindow1 = GLWindow.create(screen, glCaps);
Assert.assertNotNull(glWindow1);
Assert.assertEquals(false, glWindow1.isVisible());
Assert.assertEquals(false, glWindow1.isNativeValid());
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 14a36c573..a4e4ace43 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
@@ -47,6 +47,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Window;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
@@ -69,6 +70,7 @@ public class TestParenting04SWT extends UITestCase {
Shell shell2 = null;
Composite composite1 = null;
Composite composite2 = null;
+ com.jogamp.newt.Display swtNewtDisplay = null;
@BeforeClass
public static void initClass() {
@@ -98,6 +100,7 @@ public class TestParenting04SWT extends UITestCase {
composite2.setLayout( new FillLayout() );
Assert.assertNotNull( composite2 );
}});
+ swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
@After
@@ -121,6 +124,7 @@ public class TestParenting04SWT extends UITestCase {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ swtNewtDisplay = null;
display = null;
shell1 = null;
shell2 = null;
@@ -141,13 +145,15 @@ public class TestParenting04SWT extends UITestCase {
}
protected void winHopFrame2Frame(final boolean detachFirst) throws InterruptedException, InvocationTargetException {
- final GLWindow glWindow1 = GLWindow.create(glCaps);
+ com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, 0);
+
+ final GLWindow glWindow1 = GLWindow.create(screen, glCaps);
GLEventListener demo1 = new RedSquareES2();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
Animator anim1 = new Animator(glWindow1);
- final GLWindow glWindow2 = GLWindow.create(glCaps);
+ final GLWindow glWindow2 = GLWindow.create(screen, glCaps);
GLEventListener demo2 = new GearsES2();
setDemoFields(demo2, glWindow2, false);
glWindow2.addGLEventListener(demo2);
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..a760bbb27 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,58 @@ 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());
+ }
+
+ /** Probes whether AWT's EDT is alive or not. */
+ 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<POLL_DIVIDER && !awtEDTAliveFlag; wait++) {
+ try {
+ Thread.sleep(TIME_SLICE);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ return awtEDTAliveFlag;
+ }
+ }
+ /** Throws Error if {@link #isAWTEDTAlive()} returns false. */
+ public static void validateAWTEDTIsAlive() {
+ if( !isAWTEDTAlive() ) {
+ throw new Error("AWT EDT not alive");
+ }
+ }
+
+ /** Issuing {@link #validateAWTEDTIsAlive()} before calling {@link Robot#waitForIdle()}. */
+ public static void waitForIdle(Robot robot) {
+ validateAWTEDTIsAlive();
+ robot.waitForIdle();
+ }
+
public static void clearAWTFocus(Robot robot) throws InterruptedException, InvocationTargetException, AWTException {
if(null == robot) {
robot = new Robot();
@@ -247,7 +301,7 @@ public class AWTRobotUtil {
final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
centerMouse(robot, obj, onTitleBarIfWindow);
- robot.waitForIdle();
+ waitForIdle(robot);
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
final int d = getClickTimeout(obj) + 1;
@@ -279,6 +333,7 @@ public class AWTRobotUtil {
public static void requestFocus(Robot robot, Object obj, int x, int y)
throws AWTException, InterruptedException, InvocationTargetException {
+ validateAWTEDTIsAlive();
final boolean idling = robot.isAutoWaitForIdle();
final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
@@ -395,21 +450,17 @@ public class AWTRobotUtil {
}
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
- {
+ {
int tc = 0;
int j;
final long t0 = System.currentTimeMillis();
@@ -421,10 +472,12 @@ public class AWTRobotUtil {
if(DEBUG) { System.err.println(i+":"+j+" KC1.0: "+counter+" - regain focus on thread "+Thread.currentThread().getName()); }
requestFocus(null, obj);
}
+ waitForIdle(robot);
if(DEBUG) { System.err.println(i+":"+j+" KC1.1: "+counter+" on thread "+Thread.currentThread().getName()); }
awtRobotKeyPress(robot, keyCode, 50);
if(DEBUG) { System.err.println(i+":"+j+" KC1.2: "+counter+" on thread "+Thread.currentThread().getName()); }
awtRobotKeyRelease(robot, keyCode, 100);
+ waitForIdle(robot);
if(DEBUG) { System.err.println(i+":"+j+" KC1.3: "+counter); }
tc = ( null!=counter ? counter.getCount() : 1 ) - c0;
for (int wait=0; wait<POLL_DIVIDER && 1 > tc; wait++) {
@@ -540,9 +593,9 @@ public class AWTRobotUtil {
if(DEBUG) { System.err.println(i+":"+j+" MC1.0: "+counter+" - regain focus"); }
requestFocus(null, obj);
}
- final int c0 = null != counter ? counter.getCount() : 0;
+ final int c0 = null != counter ? counter.getCount() : 0;
if(DEBUG) { System.err.println(i+":"+j+" MC1.1: "+counter); }
- robot.waitForIdle();
+ waitForIdle(robot);
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
if(DEBUG) { System.err.println(i+":"+j+" MC1.2: "+counter); }
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);
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 d6e9743e0..f83cb515e 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -29,9 +29,16 @@
package com.jogamp.opengl.test.junit.util;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.lang.reflect.*;
import java.nio.FloatBuffer;
+import com.jogamp.common.os.Platform;
+
public class MiscUtils {
public static boolean atob(String str, boolean def) {
try {
@@ -148,6 +155,60 @@ 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;
+
+ public StreamDump(OutputStream out, String prefix, InputStream is, Object sync) {
+ this.is = is;
+ this.outString = null;
+ this.outStream = out;
+ this.prefix = prefix;
+ this.sync = sync;
+ }
+ public StreamDump(StringBuilder sb, InputStream is, Object sync) {
+ this.is = is;
+ this.outString = sb;
+ this.outStream = null;
+ this.prefix = null;
+ this.sync = sync;
+ }
+
+ public final boolean eos() { return eos; }
+
+ @Override
+ public void run() {
+ 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();
+ }
+ }
+ }
+ }
}
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 88ed74a3f..d143b3ca1 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
@@ -93,7 +93,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
}
queue.add(e);
if( verbose ) {
- System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e);
+ System.err.println("KEY NEWT PRESSED ["+pressed+"]: "+prefix+", "+e);
}
}
@@ -105,7 +105,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
}
queue.add(e);
if( verbose ) {
- System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e);
+ System.err.println("KEY NEWT RELEASED ["+pressed+"]: "+prefix+", "+e);
}
}
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 a81dec874..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,9 +32,15 @@ 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;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -62,12 +68,13 @@ 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 = 3*60*1000; // wait up to 3 min
+ 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;
@@ -90,6 +97,117 @@ public abstract class UITestCase {
testSupported = v;
}
+ public static void setResetXRandRIfX11AfterClass() {
+ resetXRandRIfX11AfterClass = true;
+ }
+
+ /**
+ * Iterates through all outputs and sets the preferred mode and normal rotation using RandR 1.3.
+ * <p>
+ * 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!
+ * </p>
+ */
+ @SuppressWarnings("unused")
+ public static void resetXRandRIfX11() {
+ if( NativeWindowFactory.isInitialized() && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) {
+ try {
+ final List<String> outputDevices = new ArrayList<String>();
+ // final List<String> outputSizes = new ArrayList<String>();
+ 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<outputDevices.size(); i++) {
+ final String outputDevice = outputDevices.get(i);
+ final String outputSize = null; // outputSizes.get(i);
+ final String[] cmdline;
+ if( null != outputSize ) {
+ cmdline = new String[] { "xrandr", "--output", outputDevice, "--mode", outputSize, "--rotate", "normal" };
+ } else {
+ cmdline = new String[] { "xrandr", "--output", outputDevice, "--preferred", "--rotate", "normal" };
+ }
+ System.err.println("XRandR Reset: "+Arrays.asList(cmdline));
+ final int errorCode = processCommand(cmdline, System.err, "xrandr-reset> ");
+ 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();
+ }
+ }
+ }
+ 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) {
int ml = 0;
@@ -125,6 +243,9 @@ public abstract class UITestCase {
@AfterClass
public static void oneTimeTearDown() {
// one-time cleanup code
+ if( resetXRandRIfX11AfterClass ) {
+ resetXRandRIfX11();
+ }
System.gc(); // force cleanup
singletonInstance.unlock();
}