I'm trying to create a window using GLFW. Window IS created, but after a few attempts it takes really long before window is created.
https://drive.google.com/file/d/1zq4IEjcSIJxy5wnXWLrGe46ptHMbKM5R/view?usp=sharing
I can't find any solution for this and don't know what can this be caused by.
Here's a code I am using:
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.glfw.GLFW.*;
public class Main {
public static void main(String[] args) {
System.out.println("0");
if(!glfwInit()) {
throw new IllegalStateException("GLFW couldn't be initialized!");
}
System.out.println("1");
long window = glfwCreateWindow(450,800,"Test #1",0,0);
if(window == 0) {
throw new IllegalStateException("GLFW failed to create a window!");
}
System.out.println("2");
GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window,(videoMode.width()-450)/2,(videoMode.height()-800)/2);
glfwMakeContextCurrent(window);
GL.createCapabilities();
float i = 2;
float speed = 1;
System.out.println("3");
while(!glfwWindowShouldClose(window)) {
if(i> 253 || i < 1)
speed *= -1;
i+=speed;
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor4f(0.38f,(i%255)/255,(i%255)/255,1.0f);
glVertex2f(-0.5f,0.5f);
glVertex2f(0.5f,0.5f);
glVertex2f(0.5f, -0.5f);
glVertex2f(-0.5f,-0.5f);
glEnd();
glfwSwapBuffers(window);
glfwPollEvents();
}
System.out.println("4");
glfwDestroyWindow(window);
glfwTerminate();
System.out.println("5");
}
}
Program's output is
0
//Now for a really long time nothing
1
2
3
So it looks like it takes really long to initialize glfw, but I have no idea how to fix it.
After some research I found out, that the problem was related to USB Input Device - in my case - Corsair k55 keyboard.
From some articles and github issues I learend, that that bug is also caused by some other devices (In many cases Corsair, but not only).
The fix is:
Hope it helps ;)