Failed to PASS test case: jme3test.awt.TestCanvas on jme-3.7.0 with lwjgl3

> Task :jme3-examples:jme3test.awt.TestSafeCanvas.main()
11�� 06, 2024 5:06:30 ���� com.jme3.system.JmeDesktopSystem initialize
��Ϣ: Running on jMonkeyEngine 3.8.0-SNAPSHOT
 * Branch: unknown
 * Git Hash: 
 * Build Date: 2024-11-06
11�� 06, 2024 5:06:32 ���� com.jme3.system.lwjgl.LwjglContext printContextInitInfo
��Ϣ: LWJGL 3.3.3+5 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Win32 WGL Null EGL OSMesa VisualC DLL
11�� 06, 2024 5:06:32 ���� com.jme3.system.lwjgl.LwjglCanvas printContextInitInfo
��Ϣ: Initializing LWJGL3-AWT with jMonkeyEngine
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Rreen Size: 8
 *  Blue Size: 8
 *  Alpha Size: 0
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 3
 *  Minor Version: 2
 *  Forward Compatible: false
 *  Profile: COMPATIBILITY
 *  API: GL
 *  Debug: false
 *  Swap Interval: 1
 *  SRGB (Gamma Correction): true
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false
11�� 06, 2024 5:06:32 ���� com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
��Ϣ: OpenGL Renderer Information
 * Vendor: ATI Technologies Inc.
 * Renderer: AMD Radeon(TM) Vega 8 Graphics 
 * OpenGL Version: 3.2.0 Core Profile Context 22.20.27.09.230330
 * GLSL Version: 4.60
 * Profile: Core
11�� 06, 2024 5:06:32 ���� com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
����: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
11�� 06, 2024 5:06:33 ���� com.jme3.audio.openal.ALAudioRenderer initOpenAL
��Ϣ: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.23.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_output_mode ALC_SOFT_pause_device ALC_SOFT_reopen_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STATIC_BUFFER AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFT_buffer_length_query AL_SOFT_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFT_gain_clamp_ex AL_SOFTX_hold_on_disconnect AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize AL_SOFT_source_start_delay AL_SOFT_UHJ AL_SOFT_UHJ_ex
11�� 06, 2024 5:06:33 ���� com.jme3.audio.openal.ALAudioRenderer initOpenAL
��Ϣ: Audio effect extension version: 1.0
11�� 06, 2024 5:06:33 ���� com.jme3.audio.openal.ALAudioRenderer initOpenAL
��Ϣ: Audio max auxiliary sends: 2
11�� 06, 2024 5:06:35 ���� com.jme3.app.LegacyApplication handleError
����: Exception while creating the OpenGL context
java.awt.AWTException: sRGB color space requested but WGL_EXT_framebuffer_sRGB is unavailable
	at org.lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:438)
	at org.lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:156)
	at com.jme3.system.lwjgl.LwjglCanvas$LwjglAWTGLCanvas.beforeRender(LwjglCanvas.java:248)
	at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:623)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:719)
	at java.base/java.lang.Thread.run(Thread.java:1583)

11�� 06, 2024 5:06:38 ���� com.jme3.system.lwjgl.LwjglCanvas$LwjglAWTGLCanvas removeNotify
����: Windows does not support this functionality: remove(__canvas__)

build.gradle changed to lwjgl3

//    implementation project(':jme3-lwjgl')
    implementation project(':jme3-lwjgl3')

System: win11
JDK:
openjdk version “21.0.3” 2024-04-16 LTS
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

JME:
branches: - master (2024-11-3)

This is unexpected, I will start investigating the cause of said error in Windows 11.

  • SRGB (Gamma Correction): true

If you turn off gamma correction (srgb), does it work or does the error still appear?, that the sRGB extension is not available is strange…

11�� 06, 2024 5:06:38 ���� com.jme3.system.lwjgl.LwjglCanvas$LwjglAWTGLCanvas removeNotify
����: Windows does not support this functionality: remove(canvas)

I see you tried to remove it from the canvas (or recreate it); This feature is not supported by lwjgl-awt (especially on Windows)

[ EDIT ]
You can turn on a small debugger for the effective inputs when initializing lwjgl-awt (that data should work) as follows:

AppSettings settings = new AppSettings(true);
settings.putBoolean("GLDataEffectiveDebug", true);

How to turn off gamma correction ?
Debug info as below:

> Task :jme3-examples:jme3test.awt.TestCanvas.main()
��Ϣ JmeDesktopSystem 12:15:01 Running on jMonkeyEngine 3.8.0-SNAPSHOT
 * Branch: unknown
 * Git Hash: 
 * Build Date: 2024-11-07
��Ϣ LwjglContext 12:15:02 LWJGL 3.3.3+5 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Win32 WGL Null EGL OSMesa VisualC DLL
��Ϣ LwjglCanvas 12:15:02 Initializing LWJGL3-AWT with jMonkeyEngine
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Rreen Size: 8
 *  Blue Size: 8
 *  Alpha Size: 0
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 3
 *  Minor Version: 2
 *  Forward Compatible: false
 *  Profile: COMPATIBILITY
 *  API: GL
 *  Debug: false
 *  Swap Interval: 1
 *  SRGB (Gamma Correction): true
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false
��Ϣ GLRenderer 12:15:03 OpenGL Renderer Information
 * Vendor: ATI Technologies Inc.
 * Renderer: AMD Radeon(TM) Vega 8 Graphics 
 * OpenGL Version: 3.2.0 Core Profile Context 22.20.27.09.230330
 * GLSL Version: 4.60
 * Profile: Core
���� GLRenderer 12:15:03 Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
��Ϣ ALAudioRenderer 12:15:04 Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.23.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_output_mode ALC_SOFT_pause_device ALC_SOFT_reopen_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STATIC_BUFFER AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFT_buffer_length_query AL_SOFT_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFT_gain_clamp_ex AL_SOFTX_hold_on_disconnect AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize AL_SOFT_source_start_delay AL_SOFT_UHJ AL_SOFT_UHJ_ex
��Ϣ ALAudioRenderer 12:15:04 Audio effect extension version: 1.0
��Ϣ ALAudioRenderer 12:15:04 Audio max auxiliary sends: 2
���� LegacyApplication 12:15:04 Exception while creating the OpenGL context
java.awt.AWTException: sRGB color space requested but WGL_EXT_framebuffer_sRGB is unavailable
	at org.lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:438)
	at org.lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:156)
	at com.jme3.system.lwjgl.LwjglCanvas$LwjglAWTGLCanvas.beforeRender(LwjglCanvas.java:248)
	at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:623)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:719)
	at java.base/java.lang.Thread.run(Thread.java:1583)
[ DEBUGGER ] :Effective data to initialize the LWJGL3-AWT context
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Rreen Size: 8
 *  Blue Size: 8
 *  Alpha Size: 8
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 0
 *  Minor Version: 0
 *  Forward Compatible: false
 *  Profile: null
 *  API: GL
 *  Debug: false
 *  Swap Interval: null
 *  SRGB (Gamma Correction): false
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false

If you want to disable the srgb (gamma correction) option you can do it as follows:

AppSettings settings = new AppSettings(true);
settings.setGammaCorrection(false);

It seems that the “effective data” indicates that srgb should be disabled…

1 Like

After I turn off the gamma correction , the program run as expected.

> Task :jme3-examples:jme3test.awt.TestCanvas.main()
��Ϣ JmeDesktopSystem 13:20:04 Running on jMonkeyEngine 3.8.0-SNAPSHOT
 * Branch: unknown
 * Git Hash: 
 * Build Date: 2024-11-08
��Ϣ LwjglContext 13:20:05 LWJGL 3.3.3+5 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Win32 WGL Null EGL OSMesa VisualC DLL
��Ϣ LwjglCanvas 13:20:05 Initializing LWJGL3-AWT with jMonkeyEngine
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Rreen Size: 8
 *  Blue Size: 8
 *  Alpha Size: 0
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 3
 *  Minor Version: 2
 *  Forward Compatible: false
 *  Profile: COMPATIBILITY
 *  API: GL
 *  Debug: false
 *  Swap Interval: 1
 *  SRGB (Gamma Correction): false
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false
��Ϣ GLRenderer 13:20:06 OpenGL Renderer Information
 * Vendor: ATI Technologies Inc.
 * Renderer: AMD Radeon(TM) Vega 8 Graphics 
 * OpenGL Version: 3.2.0 Core Profile Context 22.20.27.09.230330
 * GLSL Version: 4.60
 * Profile: Core
��Ϣ ALAudioRenderer 13:20:07 Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.23.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_output_mode ALC_SOFT_pause_device ALC_SOFT_reopen_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STATIC_BUFFER AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFT_buffer_length_query AL_SOFT_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFT_gain_clamp_ex AL_SOFTX_hold_on_disconnect AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize AL_SOFT_source_start_delay AL_SOFT_UHJ AL_SOFT_UHJ_ex
��Ϣ ALAudioRenderer 13:20:07 Audio effect extension version: 1.0
��Ϣ ALAudioRenderer 13:20:07 Audio max auxiliary sends: 2
[ DEBUGGER ] :Effective data to initialize the LWJGL3-AWT context
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Rreen Size: 8
 *  Blue Size: 8
 *  Alpha Size: 8
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 4
 *  Minor Version: 6
 *  Forward Compatible: false
 *  Profile: COMPATIBILITY
 *  API: GL
 *  Debug: false
 *  Swap Interval: null
 *  SRGB (Gamma Correction): false
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false

BUT new problem comes:
when choose : remove canvas. This info comes out:

���� LwjglAWTGLCanvas 13:21:02 Windows does not support this functionality: remove(__canvas__)


if “add canvas” after “remove canvas”, there will no new warning message shown and app run like:

"stop/start canvas"will restore the normal screen.

if choose: "switch to tab #2 " inthe first place. The same warning message

���� LwjglAWTGLCanvas 13:23:09 Windows does not support this functionality: remove(__canvas__)

Another problem appeared:
mouse pointer position isn’t correct.
In my app, the cube should always follow mouse cursor with it’s center, but in lwjgl3 it is incorrect.
ScreenPrint don’t catch mouse cursor, so I post my PS pseudo here


public void update(float tpf) {
        app.getGuiNode().getChild("blue cube").rotate(tpf, tpf, tpf);
        Vector2f t = inputManager.getCursorPosition();
        app.getGuiNode().getChild("blue cube").setLocalTranslation(t.x,t.y,0);
    }

Great!

lwjgl-awt does not support this option at the moment (especially with Windows), removing the canvas and reintegrating it into an AWT/Swing component breaks it, so it throws a warning…

This action is similar or the same as removing the canvas from a component, which will break it.

What the jme example does in this case is remove the canvas from the tab and then add it to the next one (i.e. remove and add).

I did some tests (on both Windows and Linux), but I couldn’t break jme3 (this error doesn’t appear); So I’m wondering if you have something configured wrong or if I’m overlooking something.

[ some screenshots ]



My cursor does not appear in the screenshot, however it is centered and the cube follows my cursor without problems.

Works as it should regardless of whether it is with AWT or GLFW.

[ test code ]

  1. First test with a cube in 3D space (3D node).

Just to note, if the camera doesn’t have a parallel projection, the cube doesn’t move next to the mouse cursor due to perspective (it doesn’t matter if it’s with AWT or GLFW)

public class HelloJME3 extends SimpleApplication {

    private Geometry geom;

    public static void main(String[] args){
        HelloJME3 app = new HelloJME3();
        app.start(); 
    }

    @Override
    public void simpleInitApp() {
        getFlyByCamera().setEnabled(false);
        Camera camera = getCamera();

        float cameraDistanceFrustum = 10f;

        camera.setParallelProjection(true);
        float aspect = (float) camera.getWidth() / camera.getHeight();
        camera.setFrustum(-500, 500, -aspect * cameraDistanceFrustum, aspect * cameraDistanceFrustum, cameraDistanceFrustum, -cameraDistanceFrustum);
        camera.setLocation(new Vector3f(0, 0, 0));


        Box b = new Box(1, 1, 1);
        geom = new Geometry("Box", b); 
        Material mat = new Material(assetManager,  "Common/MatDefs/Misc/Unshaded.j3md");  // create a simple material
        mat.setColor("Color", ColorRGBA.Blue); 
        geom.setMaterial(mat); 
        rootNode.attachChild(geom); 
    }

    @Override
    public void simpleUpdate(float tpf) {
        Vector3f pos = getCamera().getWorldCoordinates(inputManager.getCursorPosition(), 0f).multLocal(1, 1, 1);
        geom.setLocalTranslation(pos.x, pos.y, 0);
    }
}
  1. Second test, with a 3D cube in a 2D space (in the UI node)
public class TestZOrder extends SimpleApplication {

    Geometry geom;
    public static void main(String[] args){
        TestZOrder app = new TestZOrder();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        getFlyByCamera().setEnabled(false);
        
        Box b = new Box(100, 100, 100);
        geom = new Geometry("Box", b);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.randomColor());

        geom.setMaterial(mat);
        guiNode.attachChild(geom);
    }

    @Override
    public void simpleUpdate(float tpf) {
        Vector2f pos = inputManager.getCursorPosition();
        geom.setLocalTranslation(pos.x, pos.y, 0f);
    }
}
3 Likes