Good evening,
I wrote no code for a while now already and decided to start again.
But I have a problem in the Window class i wrote. (Window.java)Strip down
Class usage:
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.glClear;
import static org.lwjgl.opengl.GL11.glClearColor;
import java.util.stream.IntStream;
import org.lwjgl.glfw.GLFW;
public class WindowTest {
public static void main(String... strings) {
Window.startUp(WindowTest::setUp);
}
private static void setUp() {
int[] wCount = { 0 };
Runnable createWindow = () -> {
Window window = new Window("Window: " + (++wCount[0]));
window.addRenderer(w -> {
double t = GLFW.glfwGetTime();
glClearColor((float) (Math.sin(t / 7)+1)/2, (float) (Math.sin(t / 11)+1)/2, (float) (Math.sin(t / 3)+1)/2, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
w.swapBuffer();
if (w.shouldClose()) {
w.destroy();
if (0 >= --wCount[0])
Window.shutDown();
}
});
window.setVisible(true);
};
IntStream.range(0, 5).forEach(i -> createWindow.run());
}
}
I occasionally recive a java.lang.IllegalStateException when I keep resizing a window with my mouse (Sometimes it takes some time to occure).
In the moment I simply catch and ignore the Exception which works totally fine.
I guess it is a threading error :clue:
Exception in thread "GL THREAD" java.lang.IllegalStateException: GLFW error [0x10008]: WGL: Failed to make context current
at org.lwjgl.glfw.GLFWErrorCallback$2.invoke(GLFWErrorCallback.java:104)
at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:23)
at org.lwjgl.system.JNI.invokePV(Native Method)
at org.lwjgl.glfw.GLFW.glfwMakeContextCurrent(GLFW.java:3318)
at cjg.utilitys.gl.Window$1.run(Window.java:60)
Probably somebody can help me with this. I wish you a nice day anyway. Tomorrow is friday
-ClaasJG