mhdew

cse422_class 01

Sep 24th, 2021
703
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glut.h>
  2. #include <stdio.h>
  3. #include <GL/gl.h>
  4.  
  5. void init(void)
  6. {
  7.   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
  8.   glMatrixMode(GL_PROJECTION);  // To specify which matrix is the current matrix & projection applies subsequent matrix to projecton matrix stack
  9.   glLoadIdentity();  
  10.   // glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
  11.   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
  12. }
  13.  
  14.  
  15. void display(){
  16.     // wirte code here
  17.  
  18.     glClear(GL_COLOR_BUFFER_BIT);
  19.     glColor3f(0,1,0);
  20.     glBegin(GL_TRIANGLES);
  21.  
  22.     glVertex2d(10,10);
  23.     glVertex2d(30,10);
  24.     glVertex2d(50,10);
  25.  
  26.     glEnd();
  27.     glFlush();
  28.  
  29.     glutSwapBuffers();
  30. }
  31.  
  32. void display2(){
  33.     glClear(GL_COLOR_BUFFER_BIT);
  34.  
  35.     glColor3f(1,0,0);
  36.     glBegin(GL_POLYGON);
  37.  
  38.     glVertex2d(100,100);
  39.     glVertex2d(300,300);
  40.     glVertex2d(100,300);
  41.     glVertex2d(300,100);
  42.  
  43.     glEnd();
  44.     glFlush();
  45.  
  46.     glutSwapBuffers();
  47. }
  48.  
  49. int main(int argc,char **argv){
  50.    
  51.     glutInit(&argc,argv);
  52.     glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
  53.    
  54.     glutInitWindowPosition(0,0);
  55.     glutInitWindowSize(500,500);
  56.     glutCreateWindow("Lab Final");
  57.     init();
  58.     glutDisplayFunc(display2);
  59.     glutMainLoop();
  60.     return 0;
  61. }
  62.  
  63.  
RAW Paste Data