rajath_pai

DEMO

Apr 3rd, 2021 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.37 KB | None | 0 0
  1. #include <windows.h> //Don't include this for Ubuntu OS
  2. #include <GL/glut.h> //OpenGL library
  3. #include <stdio.h> //Standard Input Output
  4. #include <math.h> //For mathematical operations
  5.  
  6. void display(){
  7.     glClearColor(0,0,0,0);  //sets color glClearColor(R,G,B,alpha);
  8.     glClear(GL_COLOR_BUFFER_BIT);   //set color sent the buffer
  9.    
  10.     glPointSize(30);    //setting the size of the point
  11.     glColor3f(1,0,1);   //you can set it here and all the objects will have the same color
  12.     glBegin(GL_POINTS);
  13.     glVertex2d(-1,-1);
  14.     glVertex2d(-0.7,0.3);
  15.     glColor3f(1,1,1);
  16.     glVertex2d(-0.6,0.4);
  17.     glColor3f(1,1,0);
  18.     glVertex2d(-0.5,0.5);
  19.     glColor3f(1,0,0);
  20.     glVertex2d(-0.4,0.4);
  21.     glColor3f(0,1,1);
  22.     glVertex2d(-0.5,0.3);
  23.     glEnd();
  24.  
  25.     glBegin(GL_LINES);
  26.     glColor3f(0,1,1);
  27.     glVertex2d(-0.6,-0.6);
  28.     glColor3f(1,1,0);
  29.     glVertex2d(-0.3,-0.6);
  30.     glColor3f(1,1,1);
  31.     glVertex2d(-0.6,-0.3);
  32.     glColor3f(1,0,0);
  33.     glVertex2d(-0.3,-0.3);
  34.     glEnd();
  35.  
  36.     glBegin(GL_LINE_STRIP);
  37.     glColor3f(1,1,0);
  38.     glVertex2d(0.3,0.6);
  39.     glColor3f(0,1,1);
  40.     glVertex2d(0.6,0.6);
  41.     glColor3f(1,1,1);
  42.     glVertex2d(0.6,0.3);
  43.     glColor3f(1,0,0);
  44.     glVertex2d(0.3,0.3);
  45.     glEnd();
  46.  
  47.     glBegin(GL_LINE_LOOP);
  48.     glColor3f(1,1,0);
  49.     glVertex2d(0.3,-0.6);
  50.     glColor3f(0,1,1);
  51.     glVertex2d(0.6,-0.6);
  52.     glColor3f(1,1,1);
  53.     glVertex2d(0.6,-0.3);
  54.     glColor3f(1,0,0);
  55.     glVertex2d(0.3,-0.3);
  56.     glEnd();
  57.  
  58.     glBegin(GL_POLYGON);
  59.     glColor3f(1,1,0);
  60.     glVertex2d(0,0.5);
  61.     glColor3f(0,1,1);
  62.     glVertex2d(0.5,0);
  63.     glColor3f(1,1,1);
  64.     glVertex2d(0,-0.5);
  65.     glColor3f(1,0,0);
  66.     glVertex2d(-0.5,0);
  67.     glEnd();
  68.  
  69.     glFlush();  //used to push/display the information stored in the buffer to the screen
  70. }
  71.  
  72. int main(int argc,char **argv){
  73.  
  74.     glutInit(&argc, argv);
  75.     glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
  76.     glutInitWindowSize(1000,1000); //initilizing the window size
  77.     glutInitWindowPosition(0,0);    //initilizing the position
  78.     glutCreateWindow("Demo");       //naming the window
  79.     glutDisplayFunc(display);       //displaying the function
  80.     glutMainLoop();                 //
  81.     return 0;
  82. }
  83.  
  84. //argc - argument count
  85. //argv - argument value
  86. //used to pass arguments when you run the program
  87. //for example /a.out hello
  88. //it will print hello if
  89.  
Add Comment
Please, Sign In to add comment