Buat
Warna Pelangi yang terdiri dari 7 warna
Syntax:
#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
void display(void)
{
/* bersihkanlayardarititik pixel
yang masihada */
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 0.0);
glLineWidth(20);
glBegin(GL_LINE_STRIP);
glColor3f (1.0, 0.0, 0.0);
glVertex3f (-0.2, 0.5, 0.0);
glColor3f (1.0, 1.0, 0.0);
glVertex3f (-0.2, 0.3, 0.0);
glColor3f (1.0, 1.0, 0.1);
glVertex3f (-0.2, 0.0, 0.0);
glColor3f (0.0, 1.0, 0.0);
glVertex3f (-0.2, -0.3, 0.0);
glColor3f (0.0, 0.0, 1.0);
glVertex3f (-0.2, -0.5, 0.0);
glColor3f (1.0, 0.0, 0.1);
glVertex3f (-0.2, -0.7, 0.0);
glColor3f (1.0, 0.0, 1.0);
glVertex3f (-0.2, -0.9, 0.0);
glEnd();
glFlush ();
}
void kunci(unsigned char key, int
x, int y)
{
switch (key)
{
case 27 :
case 'q':
exit(0);
break;
}
glutPostRedisplay();
}
int main(int argc, char *argv[])
{
glutInitWindowSize(200,200);
glutInitWindowPosition(100,100);
glutInitDisplayMode(GLUT_RGB |
GLUT_SINGLE);
glutCreateWindow("DINAR");
glutDisplayFunc(display);
glutKeyboardFunc(kunci);
glutMainLoop();
return 0;
}
Output: