Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdlib.h>
- #include <GL/glut.h>
- #include <math.h>
- int x=0;
- int z=0;
- int z2=90;
- void drawQuad1(void)
- {
- glBegin (GL_POLYGON);
- glColor3f(0.0,0.0,0.0);
- glVertex2i(0,1);
- glVertex2i(-100,0);
- glColor3f(0.0,0.0,0.0);
- glVertex2i(-100,20);
- glVertex2i(0,20);
- glEnd();
- }
- void botol(void)
- {
- glBegin (GL_POLYGON);
- glColor3f(1.0,0.0,0.0); //R
- glVertex2i(0,1);
- glColor3f(1.0,0.0,0.0); //Y
- glVertex2i(-100,0);
- glColor3f(1.0,0.0,0.0); //B
- glVertex2i(-100,-100);
- glColor3f(1.0,0.0,0.0); //Y
- glVertex2i(0,-100);
- glEnd();
- }
- void renderScene()
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glClearColor(1,1,1,0);
- glLoadIdentity();
- botol();
- glRotatef(x,0,0,1);
- if (z <= 90)
- {
- x-=1;
- z+=1;
- }
- if (z > 90)
- {
- x+=1;
- z2-=1;
- }
- if (z2 < 0)
- {
- x-=1;
- z=0;
- z2=90;
- }
- drawQuad1();
- glFlush();
- }
- void timer (int value)
- {
- glutPostRedisplay();
- glutTimerFunc(10,timer,0);
- }
- void reshape(int w,int h)
- {
- glViewport(0,0,(GLsizei)w,(GLsizei)h);
- glMatrixMode(GL_PROJECTION);
- gluOrtho2D(-320,320.0,-320,320);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc, char* argv[])
- {
- glutInit(&argc,argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(1000,1000);
- glutInitWindowPosition(0,0);
- glutCreateWindow("2110161022 - Animasi Gelas");
- glutDisplayFunc(renderScene);
- glutReshapeFunc(reshape);
- glutTimerFunc(1,timer,0);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement