Jump to content
  • Advertisement
Sign in to follow this  
javisam376

OpenGL Animation in openGL help needed

This topic is 3450 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

I want to animate a simple object using open GL. I want to move it across the window by changing its x,y and z properties and rotate it. I was thinking about using the method called in glutIdleFunc to change the values of x, y and z coordinates and the angle.. I am using visual studio c++ and i am not having the desired effects on the animation... i am doing something like: glfloat teapotPos[3] = {0,0,0}; glfloat teapotAngle = 0; teapotMaterial[][4]= {{0.2f, 0.3f, 0.5f, 0.8f}, ...., {0.1f, 0.5f, 0.5f, 0.6f}}; void animate(){ /* Change x, y, z and angle of teapot*/ } void display(){ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glRotated(angle, 0.0, 0.0, 1.0 ); glTranslatef(teapotPos[0], teapotPos[1], teapotPos[2]); glColor3d(0.7, 0.9, 0.7); glMaterialfv( GL_FRONT, GL_AMBIENT, teapotMaterial[0] ); glMaterialfv( GL_FRONT, GL_DIFFUSE, teapotMaterial[1]); glMaterialfv( GL_FRONT, GL_SPECULAR, teapotMaterial[2] ); glMaterialf ( GL_FRONT, GL_SHININESS, 1.5f ); glutSolidTeapot(0.15); glutSwapBuffers( ); } int main( int argc, char** argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutInitWindowPosition( 50, 50 ); glutInitWindowSize( 512, 512 ); glutCreateWindow( "ANIMATION" ); glutDisplayFunc( display ); glutIdleFunc(animate); glEnable( GL_DEPTH_TEST ); glutMainLoop( ); return 0; } I am using open GL and Visual Studio 2005.... Any comments to the code included or examples / simple tutorials or code examples are welcome...

Share this post


Link to post
Share on other sites
Advertisement
The idea is very much correct. But what is actually happening and what do you expect to happen? The code you removed from the animate-function is important.

Share this post


Link to post
Share on other sites
Thanks for your response Brother Bob...

Its just to follow a formula for the position of the teapot (x,y,z) based on the elapsed time... The formula finds the right values based on the time, and they range from 0 to 30.... my problem is to keep the motion inside the window....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!