Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Tuesday, 19 November 2019

House Program

#include<stdio.h>
#include<GL/glut.h>
void myInit(){
  glClearColor(1.0,1.0,1.0,1.0);
  
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0.0,10.0,0.0,10.0);
  glMatrixMode(GL_MODELVIEW);
  


}
void display(){
  glClear(GL_COLOR_BUFFER_BIT);
  glPointSize(15.0);
  //glLineSize(10.0);
  glBegin(GL_POLYGON);
  glColor3f(1.0,0.0,0.0);
    glVertex2f(2.0,1.0);
    glVertex2f(6.0,1.0);
    glVertex2f(6.0,6.0);
    glVertex2f(2.0,6.0);

  glEnd();
  glBegin(GL_POLYGON);
    glColor3f(0.6,0.0,1.0);
    glVertex2f(2.0,6.0);
    glVertex2f(6.0,6.0);
    glVertex2f(4.0,8.0);
  glEnd();
  glBegin(GL_POLYGON);
    glColor3f(0.0,0.0,0.0);
    glVertex2f(2.5,4.5);
    glVertex2f(3.5,4.5);
    glVertex2f(3.5,5.5);
    glVertex2f(2.5,5.5);
  glEnd();
   glBegin(GL_POLYGON);
    glColor3f(0.0,0.0,0.0);
    glVertex2f(4.5,4.5);
    glVertex2f(5.5,4.5);
    glVertex2f(5.5,5.5);
    glVertex2f(4.5,5.5);
  glEnd();
  glBegin(GL_POLYGON);
    glColor3f(1.0,1.0,1.0);
    glVertex2f(3.5,1.1);
    glVertex2f(4.5,1.1);
    glVertex2f(4.5,3.5);
    glVertex2f(3.5,3.5);
  glEnd();
  glBegin(GL_POLYGON);
    glColor3f(1.0,1.0,0.0);
    glVertex2f(4.0,1.1);
    glVertex2f(4.5,1.1);
    glVertex2f(4.5,3.5);
    glVertex2f(4.0,3.2);
  glEnd();
  glFlush();

}
int main(int argc,char **argv){
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
  glutInitWindowSize(400,400);
  glutInitWindowPosition(100,100);
  glutCreateWindow("Program on Input Inraction");
  glutDisplayFunc(display);
  myInit();
  glutMainLoop();
  return 0;
}


//gcc -o foo new.c -lglut -lGLU -lGL -lm

0 comments:

Post a Comment