A program in C/C++ using OpenGL to draw a hard wire house

QuestionsA program in C/C++ using OpenGL to draw a hard wire house
akankshat.ngPublished on: 10/18/2018 5:33:54 PM

 Write a program in C/C using OpenGL to draw a hard wire house as shown in figure given below. Use basic primitives of openGL.


1 Answers
Best Answer 0
admin 10/16/2018 1:27:00 AM

#include<windows.h>

#include<gl/gl.h>

#include<gl/glu.h>

#include<gl/glut.h>

void myInit(void)

{

glClearColor(1.0,1.0,1.0,0.0);

glColor3f(0.0f,0.0f,0.0f);

glPointSize(4.0);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,800.0,0.0,600.0);

}

void myDisplay(void)

{

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);

glColor3f(0.0f,0.0f,1.0f);

glVertex2i(100,100);

glVertex2i(200,100);

glVertex2i(200,200);

glVertex2i(100,200);

glEnd();

glBegin(GL_TRIANGLES);

glColor3f(1.0f,0.0f,0.0f);

glVertex2i(100,200);

glVertex2i(150,300);

glVertex2i(200,200);

glEnd();

glFlush();

}

void main(int argc,char **argv)

{

glutInit(&argc,argv);

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

glutInitWindowSize(800,600);

glutInitWindowPosition(100,100);

glutCreateWindow("OpenGl Window");

myInit();

glutDisplayFunc(myDisplay);

glutMainLoop();

}

Edit