Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h> //Don't include this for Ubuntu OS
- #include <GL/glut.h> //OpenGL library
- #include <stdio.h> //Standard Input Output
- #include <math.h> //For mathematical operations
- void display(){
- glClearColor(0,0,0,0); //sets color glClearColor(R,G,B,alpha);
- glClear(GL_COLOR_BUFFER_BIT); //set color sent the buffer
- glPointSize(30); //setting the size of the point
- glColor3f(1,0,1); //you can set it here and all the objects will have the same color
- glBegin(GL_POINTS);
- glVertex2d(-1,-1);
- glVertex2d(-0.7,0.3);
- glColor3f(1,1,1);
- glVertex2d(-0.6,0.4);
- glColor3f(1,1,0);
- glVertex2d(-0.5,0.5);
- glColor3f(1,0,0);
- glVertex2d(-0.4,0.4);
- glColor3f(0,1,1);
- glVertex2d(-0.5,0.3);
- glEnd();
- glBegin(GL_LINES);
- glColor3f(0,1,1);
- glVertex2d(-0.6,-0.6);
- glColor3f(1,1,0);
- glVertex2d(-0.3,-0.6);
- glColor3f(1,1,1);
- glVertex2d(-0.6,-0.3);
- glColor3f(1,0,0);
- glVertex2d(-0.3,-0.3);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glColor3f(1,1,0);
- glVertex2d(0.3,0.6);
- glColor3f(0,1,1);
- glVertex2d(0.6,0.6);
- glColor3f(1,1,1);
- glVertex2d(0.6,0.3);
- glColor3f(1,0,0);
- glVertex2d(0.3,0.3);
- glEnd();
- glBegin(GL_LINE_LOOP);
- glColor3f(1,1,0);
- glVertex2d(0.3,-0.6);
- glColor3f(0,1,1);
- glVertex2d(0.6,-0.6);
- glColor3f(1,1,1);
- glVertex2d(0.6,-0.3);
- glColor3f(1,0,0);
- glVertex2d(0.3,-0.3);
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f(1,1,0);
- glVertex2d(0,0.5);
- glColor3f(0,1,1);
- glVertex2d(0.5,0);
- glColor3f(1,1,1);
- glVertex2d(0,-0.5);
- glColor3f(1,0,0);
- glVertex2d(-0.5,0);
- glEnd();
- glFlush(); //used to push/display the information stored in the buffer to the screen
- }
- int main(int argc,char **argv){
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
- glutInitWindowSize(1000,1000); //initilizing the window size
- glutInitWindowPosition(0,0); //initilizing the position
- glutCreateWindow("Demo"); //naming the window
- glutDisplayFunc(display); //displaying the function
- glutMainLoop(); //
- return 0;
- }
- //argc - argument count
- //argv - argument value
- //used to pass arguments when you run the program
- //for example /a.out hello
- //it will print hello if
Add Comment
Please, Sign In to add comment