Jump to content
  • Advertisement
Sign in to follow this  
tomba

OpenGL linking a game loop in glut

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!