mouse input question
how do i get get the mouse coords to move an object on the screen? is there a function in glut that i can use?
alright why doesnt this work? if i move the mouse shouldnt it move what i have displayed or am i doing this wrong?
void processmousecords(int x,int y){ xrot=x; yrot=y;}void renderscene(){ GLfloat x; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glRotatef(x,1.0f,0.0f,0.0f); glRotatef(30.0f,0.0f,0.0f,1.0f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3,GL_FLOAT,0,cords); glDrawElements(GL_TRIANGLE_STRIP,1600,GL_UNSIGNED_INT,corners); glPopMatrix(); glutSwapBuffers();}void main(){ GLfloat x=0.0; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("game engine console"); glutReshapeFunc(ChangeSize); glutDisplayFunc(renderscene); setuprc(); glutMotionFunc(processmousecords); glutMainLoop();}
omegasyphon, try adding
glutPostRedisplay();
in your processmouse inputs function. this tells the renderer that the function has made an update.
paulP,
yes there is a way without glut. you use regular Win32 code. the topic goes into the WinProc, which i don''t wanna discuss, but that is where you would put your mouse processing commands.
a2k
glutPostRedisplay();
in your processmouse inputs function. this tells the renderer that the function has made an update.
paulP,
yes there is a way without glut. you use regular Win32 code. the topic goes into the WinProc, which i don''t wanna discuss, but that is where you would put your mouse processing commands.
a2k
... and remove the local x variables. The one in main is never used and you should use yrot or xrot in renderscene.
To answer some of your questions: Yes you can get mouse input without using the GLUT... Its called DirectInput, and it kicks ass (writing a tutorial on mouse movement with DI, and DirectAudio as we speak actually).
------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials
------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement