Sign in to follow this  
phil67rpg

open gl animation

Recommended Posts

phil67rpg    443
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
_the_phantom_    11250
Guest
This topic is now closed to further replies.
Sign in to follow this