• Advertisement
Sign in to follow this  

open gl animation

This topic is 4332 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 am still working on a pong clone and I need to animate game paddles using only the glut.h library here is my code please help #include <stdlib.h> #include <GL/glut.h> #include <math.h> #include <time.h> void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f,1.0f,1.0f); for (int i=0;i<=500;i++) { glBegin(GL_POINTS);//draw starry background glVertex2i(rand()%800,rand()%600); glEnd(); } glFlush(); glColor3f(0.0f,0.0f,1.0f);//draw blue paddle glBegin(GL_POLYGON); glVertex2i(780,260); glVertex2i(800,260); glVertex2i(800,340); glVertex2i(780,340); glVertex2i(780,260); glEnd(); glColor3f(1.0f,0.0f,0.0f);//draw red paddle glBegin(GL_POLYGON); glVertex2i(360,580); glVertex2i(440,580); glVertex2i(440,600); glVertex2i(360,800); glVertex2i(360,580); glEnd(); glColor3f(0.0f,1.0f,0.0f);//draw green paddle glBegin(GL_POLYGON); glVertex2i(0,260); glVertex2i(20,260); glVertex2i(20,340); glVertex2i(0,340); glVertex2i(0,260); glEnd(); glColor3f(1.0f,1.0f,0.0f);//draw yellow paddle glBegin(GL_POLYGON); glVertex2i(360,0); glVertex2i(440,0); glVertex2i(440,20); glVertex2i(360,20); glVertex2i(360,0); glEnd(); glFlush(); } void SetupRC(void) { glClearColor(0.0f,0.0f,0.0f,0.0f); gluOrtho2D(0.0f,800.0,0.0,600.0); } void main(void) { glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(800,600); glutInitWindowPosition(100,100); glutCreateWindow("Simple"); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); }

Share this post


Link to post
Share on other sites
Advertisement

This topic is 4332 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.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement