Caranya sama dengan yang postingan pertama tetapi hanya mengganti source code nya,,
tampilan output nya akan menampilkan seperti berikut:
- #include <GLUT/glut.h>
- void display() {
- glBegin(GL_POLYGON);
- glColor3f (1.0, 0.0, 0.0);
- glVertex3f (-1.0, -1.0, 0.0);
- glVertex3f (-1.0, 1.0, 0.0);
- glColor3f (1.0, 0.5, 0.0);
- glVertex3f (-0.75, 1.0, 0.0);
- glVertex3f (-0.75, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (1.0, 0.5, 0.0);
- glVertex3f (-0.75, -1.0, 0.0);
- glVertex3f (-0.75, 1.0, 0.0);
- glColor3f (1.0, 1.0, 0.0);
- glVertex3f (-0.5, 1.0, 0.0);
- glVertex3f (-0.5, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (1.0, 1.0, 0.0);
- glVertex3f (-0.5, -1.0, 0.0);
- glVertex3f (-0.5, 1.0, 0.0);
- glColor3f (0.0, 1.0, 0.0);
- glVertex3f (-0.25, 1.0, 0.0);
- glVertex3f (-0.25, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (0.0, 1.0, 0.0);
- glVertex3f (-0.25, -1.0, 0.0);
- glVertex3f (-0.25, 1.0, 0.0);
- glColor3f (0.0, 0.0, 1.0);
- glVertex3f (0.25, 1.0, 0.0);
- glVertex3f (0.25, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (0.0, 0.0, 1.0);
- glVertex3f (0.25, -1.0, 0.0);
- glVertex3f (0.25, 1.0, 0.0);
- glColor3f (1.0, 0.0, 0.5);
- glVertex3f (0.5, 1.0, 0.0);
- glVertex3f (0.5, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (1.0, 0.0, 0.5);
- glVertex3f (0.5, -1.0, 0.0);
- glVertex3f (0.5, 1.0, 0.0);
- glColor3f (1.0, 0.0, 1.0);
- glVertex3f (0.75, 1.0, 0.0);
- glVertex3f (0.75, -1.0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f (1.0, 0.0, 1.0);
- glVertex3f (0.75, -1.0, 0.0);
- glVertex3f (0.75, 1.0, 0.0);
- glVertex3f (1.0, 1.0, 0.0);
- glVertex3f (1.0, -1.0, 0.0);
- glEnd();
- glFlush ();
- }
- int main(int argc, char** argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE);
- glutInitWindowSize(500, 500);
- glutCreateWindow("L");
- glutDisplayFunc(display);
- glutMainLoop();
- }

 
Tidak ada komentar:
Posting Komentar