I am trying to write a simple C++ game using OpenGL. In my render loop i ask for text based input from the user but this causes the GLFW window to become unresponsive. I suspect that this happens because the window does not like it when the main thread is paused from std::cin so it behaves weirdly. If i remove the input prompt the window behaves perfectly. Can someone confirm if this is the case and what workarounds are there to fix it?


1 Answer 1


Yes. Your program is waiting for the user to give their input before continuing.

The workaround to this is to use asynchronous input.

An example of this in GLFW is to use something like this:

// Set the callback glfwSetKeyCallback(g_odin.windowManager.g_window, key_callback);
// The function that gets called on key events void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { /* ... do something ... */ }


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .