#include
sudut=2*PI*i/jumlah_titik;
glVertex2f(20*cos(sudut),20*sin(sudut));
}
glEnd();
}
void Display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0,0,0);
ypos = ypos+xdir*0.1;
if (ypos >=220)
xdir=0;
ypos = ypos+xdir*0.1;
if (ypos >=220)
xdir=-1;
ypos = ypos+xdir*0.1;
if (ypos <=0)
xdir=0;
ypos = ypos+xdir*0.1;
if (ypos <=0)
xdir=1;
glLoadIdentity();
glTranslatef(xpos,ypos,0);
Lingkaran();
glutSwapBuffers();
glutPostRedisplay();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,320.0,0.0,240.0);
glMatrixMode(GL_MODELVIEW);
}
void init()
{
glClearColor(1,1,0,0);
ypos=20;
xpos=20;
xdir=1;
}
int main(int argc,char*argv[])
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(320,240);
glutCreateWindow("Habibul Hakim = 12111042");
init();
glutDisplayFunc(Display);
glutReshapeFunc(reshape);
glutMainLoop();
}
Post a Comment
1. Jangan lupa tinggalkan Likenya ya
2. Berkomentarlah dengan baik dan sopan