Selasa, 01 Mei 2018

Membuat Rainbow/Pelangi 7 Warna OpenGL

Caranya sama dengan yang postingan pertama tetapi hanya mengganti source code nya,,

tampilan output nya akan menampilkan seperti berikut:


  1. #include <GLUT/glut.h>
  2. void display() {
  3.    
  4.     glBegin(GL_POLYGON);
  5.     glColor3f (1.00.00.0);
  6.     glVertex3f (-1.0-1.00.0);
  7.     glVertex3f (-1.01.00.0);
  8.     glColor3f (1.00.50.0);
  9.     glVertex3f (-0.751.00.0);
  10.     glVertex3f (-0.75-1.00.0);
  11.     glEnd();
  12.     glBegin(GL_POLYGON);
  13.     glColor3f (1.00.50.0);
  14.     glVertex3f (-0.75-1.00.0);
  15.     glVertex3f (-0.751.00.0);
  16.     glColor3f (1.01.00.0);
  17.     glVertex3f (-0.51.00.0);
  18.     glVertex3f (-0.5-1.00.0);
  19.     glEnd();
  20.     glBegin(GL_POLYGON);
  21.     glColor3f (1.01.00.0);
  22.     glVertex3f (-0.5-1.00.0);
  23.     glVertex3f (-0.51.00.0);
  24.     glColor3f (0.01.00.0);
  25.     glVertex3f (-0.251.00.0);
  26.     glVertex3f (-0.25-1.00.0);
  27.     glEnd();
  28.     glBegin(GL_POLYGON);
  29.     glColor3f (0.01.00.0);
  30.     glVertex3f (-0.25-1.00.0);
  31.     glVertex3f (-0.251.00.0);
  32.     glColor3f (0.00.01.0);
  33.     glVertex3f (0.251.00.0);
  34.     glVertex3f (0.25-1.00.0);
  35.     glEnd();
  36.     glBegin(GL_POLYGON);
  37.     glColor3f (0.00.01.0);
  38.     glVertex3f (0.25-1.00.0);
  39.     glVertex3f (0.251.00.0);
  40.     glColor3f (1.00.00.5);
  41.     glVertex3f (0.51.00.0);
  42.     glVertex3f (0.5-1.00.0);
  43.     glEnd();
  44.     glBegin(GL_POLYGON);
  45.     glColor3f (1.00.00.5);
  46.     glVertex3f (0.5-1.00.0);
  47.     glVertex3f (0.51.00.0);
  48.     glColor3f (1.00.01.0);
  49.     glVertex3f (0.751.00.0);
  50.     glVertex3f (0.75-1.00.0);
  51.     glEnd();
  52.     glBegin(GL_POLYGON);
  53.     glColor3f (1.00.01.0);
  54.     glVertex3f (0.75-1.00.0);
  55.     glVertex3f (0.751.00.0);
  56.     glVertex3f (1.01.00.0);
  57.     glVertex3f (1.0-1.00.0);
  58.     glEnd();
  59.     glFlush ();
  60.    
  61. }
  62. int main(int argc, char** argv) {
  63.    
  64.    
  65.     glutInit(&argc, argv);
  66.     glutInitDisplayMode(GLUT_SINGLE);
  67.     glutInitWindowSize(500500);
  68.     glutCreateWindow("L");
  69.     glutDisplayFunc(display);
  70.     glutMainLoop();
  71. }




Tidak ada komentar:

Posting Komentar