Sign in to follow this  

OpenGL linking a game loop in glut

Recommended Posts

hi i am making a 2d opengl game. if my main code is like this: void main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowPosition(100,100); glutInitWindowSize(WIN_WIDTH,WIN_HEIGHT); glutCreateWindow("RPG"); glutReshapeFunc(reshape); initGL(); initGame(); glutDisplayFunc(display); glutIdleFunc(Idle); glutKeyboardFunc(processNormalKeys); glutSpecialFunc(processSpecialKeys); glutMainLoop(); } how do u put a game loop into this? i need a detail answer in how to accurately get input in the loop also with gult. i tried something like this void Loop() { while (true) { display(); Sleep(15); UpdateMovement(); } void UpdateMovement() { if (IS_MOVING==true) { hero.x += hero_addx; hero.y += hero_addy; hero.motion(); moveCo++; } } but UpdateMovement never moves my character because it's not acessing glutKeyboardFunc() i think. so how do i link a game loop with glut and get it to work? thx for any input :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this