anonymous wrote on Sunday, June 19, 2011:
with glfwSwapInterval(1); the rendered point is lagging behind the real
mouse cursor (both windows and ubuntu on laptop and desktop pc)
glfwSwapInterval(0); makes the mouse move jerky
mouse callback does change a thing
glfwSleep fixes this problem but someone wrote that it won’t be available in
later versions
for (int i=0; i<1000000; i++) float x = sqrt(1337.0); fixes the problem as
well so I think that my pc is faster than glfw can spit the images on my
screen but this is not a good solution because it won’t work on slower/faster
systems and creates unnecessary overhead
not having that problem with freeglut so I will have to use that instead
(well…I could get another lib for threads but….)
#include <GL/glfw.h>
int main(){
int w = 640, h = 480, mx = 0, my = 0;
glfwInit();
glfwOpenWindow(w, h, 5, 6, 5, 0, 0, 0, GLFW_WINDOW);
//glfwSwapInterval(1);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, 0, h, -10, 10);
glMatrixMode(GL_MODELVIEW);
glPointSize(10);
while (!glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED)){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwGetMousePos(&mx, &my);
my = h-1-my;
glBegin(GL_POINTS);
glVertex2f(mx, my);
glEnd();
glfwSwapBuffers();
//glfwSleep(0.001);
}
glfwTerminate();
return 0;
}