So, I'm writing the rest of this supposing SwapInterval was set to 1. In fact, typically with SwapInterval set to 0, you get less lag than with it set to 1, so I suspect it was actually set to 1 the whole time. So yeah the usual approach to synchronising rendering to frame rate is with SwapInterval(1) and you weren't doing that, but that's not where the lag is coming from. GlfwSetCursorPosCallback(window, cursor_callback) Window = glfwCreateWindow(640, 480, "Following Triangle", NULL, NULL) GlfwGetFramebufferSize(window, &width, &height) Hi, and sorry if this question offends anybody, but i see people saying LotV is good, and i just wonder why that is. Static void cursor_callback(GLFWwindow *window, double xpos, double ypos) GlfwSetWindowShouldClose(window, GL_TRUE) If (key = GLFW_KEY_ESCAPE & action = GLFW_PRESS) Static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) Static void error_callback(int error, const char* description)
So I hope you can enlighten me on how to draw this efficiently. I also tried using glTranslate instead of drawing at varying coordinates, but no improvement on the lag resulted. One thing I realize is that it would suffice to shift the actual pixel values of the triangle, and not rasterize it again and again.īut is rasterizing this one triangle really that expensive? So my question is: What am I doing wrong? What leads to this lag? What I (and hopefully you) can notice, is that the triangle lags behind the cursor, it's not as tight as when dragging around even a whole window. Here's a simple program that draws a triangle following the mouse cursor's position.