Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWJGL 3.3.2 There is no OpenGL context #880

Closed
rafi612 opened this issue Apr 28, 2023 · 5 comments
Closed

LWJGL 3.3.2 There is no OpenGL context #880

rafi612 opened this issue Apr 28, 2023 · 5 comments

Comments

@rafi612
Copy link

rafi612 commented Apr 28, 2023

Version

3.3.2 (nightly)

Platform

Linux x64

JDK

OpenJDK 17.0.6

Module

OpenGL, GLFW

Bug description

Hi!
When I tried to create window using GLFW and call GL.createCapabilities to create capabilities, LWJGL throw exception with message There is no OpenGL context current in the current thread. This issue only occurs in LWJGL 3.3.2. When I used lwjgl3-awt library everything works. I also compiled latest GLFW and tested similar code, and it work, it can't be upstream issue.

My hardware:

GPU: Nvidia Quadro FX 880m
Driver: 340.108
I know this card is very old.

I also tested it on my old laptop with Intel GPU (also with Linux) and everything works.

Sample code giving me this error:

public static void main(String[] args) {
	if (!glfwInit())
	    System.err.println("Init error");

	GLFWErrorCallback.createPrint(System.err).set();

	glfwDefaultWindowHints();

	glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
	glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);

	long window = glfwCreateWindow(1280,720, "Sample Window!", NULL, NULL);
	if (window == NULL)
	    throw new RuntimeException("Failed to create the GLFW window");

	glfwMakeContextCurrent(window);

	GL.createCapabilities();

	glfwShowWindow(window);

	glfwSwapInterval(1);
	while (!glfwWindowShouldClose(window)) {
	    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	    glfwSwapBuffers(window);
	    glfwPollEvents();
	}

	glfwDestroyWindow(window);
}

Stacktrace or crash log output

Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:382)
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:311)
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:295)
	at org.example.Main.main(Main.java:78)
@Spasi
Copy link
Member

Spasi commented Apr 28, 2023

Hey @rafi612,

Could you please post the output when running with -Dorg.lwjgl.util.Debug=true -Dorg.lwjgl.util.DebugLoader=true? Then do another run, but this time add GLFWNativeGLX.setPath(GL.getFunctionProvider()) before the glfwInit call.

@rafi612
Copy link
Author

rafi612 commented Apr 28, 2023

Hey @Spasi,

Here's first output:

[LWJGL] Version: 3.3.2+13
	 OS: Linux v5.4.0-147-generic
	JRE: Linux amd64 17.0.6
	JVM: OpenJDK 64-Bit Server VM v17.0.6+10-Ubuntu-0ubuntu120.04.1 by Private Build
[LWJGL] Loading JNI library: lwjgl
	Module: org.lwjgl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
[LWJGL] Loading library: glfw
	Module: org.lwjgl.glfw
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
[LWJGL] Java 9 check intrinsics enabled
[LWJGL] Closure Registry: ConcurrentHashMap
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Loading JNI library: lwjgl_opengl
	Module: org.lwjgl.opengl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
[LWJGL] Loading library: libGL.so.1
	Module: org.lwjgl.opengl
	libGL.so.1 not found in org.lwjgl.librarypath=/tmp/lwjgl_rafal/3.3.2+13/x64
[LWJGL] Java 9 text decoding enabled
	Loaded from system paths: /lib/x86_64-linux-gnu/libGL.so.1
Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:382)
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:311)
	at org.lwjgl.opengl.GL.createCapabilities(GL.java:295)
	at org.example.Main.main(Main.java:126)

And second output with GLFWNativeGLX.setPath(GL.getFunctionProvider()) added (window is working now):

[LWJGL] Version: 3.3.2+13
	 OS: Linux v5.4.0-147-generic
	JRE: Linux amd64 17.0.6
	JVM: OpenJDK 64-Bit Server VM v17.0.6+10-Ubuntu-0ubuntu120.04.1 by Private Build
[LWJGL] Loading JNI library: lwjgl
	Module: org.lwjgl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
[LWJGL] Loading JNI library: lwjgl_opengl
	Module: org.lwjgl.opengl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
[LWJGL] Loading library: libGL.so.1
	Module: org.lwjgl.opengl
	libGL.so.1 not found in org.lwjgl.librarypath=/tmp/lwjgl_rafal/3.3.2+13/x64
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Java 9 text decoding enabled
	Loaded from system paths: /lib/x86_64-linux-gnu/libGL.so.1
[LWJGL] Loading library: glfw
	Module: org.lwjgl.glfw
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
[LWJGL] Java 9 check intrinsics enabled
[LWJGL] Closure Registry: ConcurrentHashMap
[LWJGL] Java 10 multiplyHigh enabled

@Spasi
Copy link
Member

Spasi commented Apr 28, 2023

@rafi612 Thanks! What happens if you also pass -Dorg.lwjgl.opengl.libname=libGLX.so.0? With and without the GLFWNativeGLX.setPath call.

@rafi612
Copy link
Author

rafi612 commented Apr 28, 2023

@Spasi Here's output with GLFWNativeGLX.setPath call (window works):

[LWJGL] Version: 3.3.2+13
	 OS: Linux v5.4.0-147-generic
	JRE: Linux amd64 17.0.6
	JVM: OpenJDK 64-Bit Server VM v17.0.6+10-Ubuntu-0ubuntu120.04.1 by Private Build
[LWJGL] Loading JNI library: lwjgl
	Module: org.lwjgl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
[LWJGL] Loading JNI library: lwjgl_opengl
	Module: org.lwjgl.opengl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
[LWJGL] Loading library: libGLX.so.0
	Module: org.lwjgl.opengl
	libGLX.so.0 not found in org.lwjgl.librarypath=/tmp/lwjgl_rafal/3.3.2+13/x64
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Java 9 text decoding enabled
	Loaded from system paths: /lib/x86_64-linux-gnu/libGLX.so.0
[LWJGL] Loading library: glfw
	Module: org.lwjgl.glfw
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
[LWJGL] Java 9 check intrinsics enabled
[LWJGL] Closure Registry: ConcurrentHashMap
[LWJGL] Java 10 multiplyHigh enabled

And without (window also works):

[LWJGL] Version: 3.3.2+13
	 OS: Linux v5.4.0-147-generic
	JRE: Linux amd64 17.0.6
	JVM: OpenJDK 64-Bit Server VM v17.0.6+10-Ubuntu-0ubuntu120.04.1 by Private Build
[LWJGL] Loading JNI library: lwjgl
	Module: org.lwjgl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl.so
[LWJGL] Loading library: glfw
	Module: org.lwjgl.glfw
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/libglfw.so
[LWJGL] Java 9 check intrinsics enabled
[LWJGL] Closure Registry: ConcurrentHashMap
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Loading JNI library: lwjgl_opengl
	Module: org.lwjgl.opengl
	Using SharedLibraryLoader...
	Found at: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
	Loaded from org.lwjgl.librarypath: /tmp/lwjgl_rafal/3.3.2+13/x64/liblwjgl_opengl.so
[LWJGL] Loading library: libGLX.so.0
	Module: org.lwjgl.opengl
	libGLX.so.0 not found in org.lwjgl.librarypath=/tmp/lwjgl_rafal/3.3.2+13/x64
[LWJGL] Java 9 text decoding enabled
	Loaded from system paths: /lib/x86_64-linux-gnu/libGLX.so.0
[LWJGL] Java 10 multiplyHigh enabled

@Spasi
Copy link
Member

Spasi commented Apr 29, 2023

@rafi612 Great, thanks! It is a known issue that unfortunately affects the 3.3.2 release, see this for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants