Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- #include <stdio.h>
- #include <GL/gl.h>
- void init(void)
- {
- glClearColor(0.0,0.0,0.0,0.0); //GLfloat red,green,blue,alpha initial value 0 alpha values used by glclear to clear the color buffers
- glMatrixMode(GL_PROJECTION); // To specify which matrix is the current matrix & projection applies subsequent matrix to projecton matrix stack
- glLoadIdentity();
- // glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
- gluOrtho2D(0.0,200.0,0.0,200.0); // Orthographic representation; multiply the current matrix by an orthographic matrix 2D= left right,bottom,top equivalent near=-1,far=1
- }
- void display(){
- // wirte code here
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0,1,0);
- glBegin(GL_TRIANGLES);
- glVertex2d(10,10);
- glVertex2d(30,10);
- glVertex2d(50,10);
- glEnd();
- glFlush();
- glutSwapBuffers();
- }
- void display2(){
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1,0,0);
- glBegin(GL_POLYGON);
- glVertex2d(100,100);
- glVertex2d(300,300);
- glVertex2d(100,300);
- glVertex2d(300,100);
- glEnd();
- glFlush();
- glutSwapBuffers();
- }
- int main(int argc,char **argv){
- glutInit(&argc,argv);
- glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
- glutInitWindowPosition(0,0);
- glutInitWindowSize(500,500);
- glutCreateWindow("Lab Final");
- init();
- glutDisplayFunc(display2);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement