#include<GL/glut.h>
#include<GL/gl.h>
#include<windows.h>
void init(void){
glClearColor(1.0,
1.0, 1.0, 0.0);
glLineWidth(1.0);
glColor3f(1.0,
0.0, 0.0);
glOrtho(-6,6,
-6,6, -6,6);
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2f(-5.5,0.0);
glColor3f(1.0,
0.0, 0.0);
glVertex2f(5.5,0.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(0.0,-5.3);
glColor3f(1.0,
0.0, 0.0);
glVertex2f(0.0,5.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(-1.0,1.0); //sebelAH KIRI
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(-1.0,4.0);
glColor3f(0.0,
1.0, 0.0);
glVertex2f(-5.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(-1.0,-1.0);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(-5.0,-1.0);
glColor3f(0.0,
1.0, 0.0);
glVertex2f(-5.0,-5.0);
glColor3f(0.0,
1.0, 0.0);
glVertex2f(-1.0,-5.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(1.0,1.0);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(1.0,4.0); //sebelah kanan
glColor3f(0.0,
1.0, 0.0);
glVertex2f(5.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(1.0,-1.0);
glColor3f(-1.0,
0.0, 0.0);
glVertex2f(5.0,-1.0);
glColor3f(0.0,
1.0, 0.0);
glVertex2f(5.0,-5.0);
glColor3f(0.0,
1.0, 0.0);
glVertex2f(1.0,-5.0);
glEnd();
glutSwapBuffers();
}
void main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(0,0);
glutInitWindowSize(1000,1000);
glutCreateWindow("Latihan 2");
init();
glutDisplayFunc(display);
glutMainLoop();
}
No comments:
Post a Comment