Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Shamsuddin Ahmed
- 161-15-1027
- Draw Home using lines
- */
- #include<windows.h>
- #include <GL/glut.h>
- void init(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0); // Set display window colour to white
- glMatrixMode(GL_PROJECTION); // Set projection parameters
- gluOrtho2D(0.0, 400.0, 0.0, 400.0);
- }
- void drawShapes(void)
- {
- glClear(GL_COLOR_BUFFER_BIT); // Clear display window
- //Set colour to black
- glColor3f(0.0, 0.0, 0.0);
- //Adjust the point size
- glPointSize(5.0);
- //Set colour to red
- glColor3f(1.0, 0.0, 0.0);
- // Draw an outlined triangle
- glBegin(GL_LINES);
- //Home shape Using Line
- glVertex2i(40, 20); //A
- glVertex2i(200, 20); //B
- glVertex2i(200, 20); //B
- glVertex2i(200,120); //C
- glVertex2i(200,120); //C
- glVertex2i(40, 120); //D
- glVertex2i(40, 120); //D
- glVertex2i(40, 20); //A
- //Home shape End
- // Home roof start
- glVertex2i(40, 120); //D
- glVertex2i(80, 160); //Q
- glVertex2i(80, 160); //Q
- glVertex2i(160, 160); //R
- glVertex2i(160, 160); //R
- glVertex2i(200,120); //C
- glVertex2i(200,120); //C
- glVertex2i(40, 120); //D
- //Home roof end
- //Home Door Start
- glVertex2i(100, 20); //E
- glVertex2i(100, 60); //F
- glVertex2i(100, 60); //F
- glVertex2i(140, 60); //G
- glVertex2i(140, 60); //G
- glVertex2i(140, 20); //H
- glVertex2i(140, 20); //H
- glVertex2i(100, 20); //E
- //Home Door End
- //Window Left start
- glVertex2i(60, 80); //I
- glVertex2i(80, 80); //J
- glVertex2i(80, 80); //J
- glVertex2i(80, 60); //K
- glVertex2i(80, 60); //K
- glVertex2i(60, 60); //L
- glVertex2i(60, 60); //L
- glVertex2i(60, 80); //I
- //Window Left End
- //Window Right Start
- glVertex2i(160, 80); //M
- glVertex2i(180, 80); //N
- glVertex2i(180, 80); //N
- glVertex2i(180, 60); //O
- glVertex2i(180, 60); //O
- glVertex2i(160, 60); //P
- glVertex2i(160, 60); //P
- glVertex2i(160, 80); //M
- //Windows Right End
- glEnd();
- glFlush(); // Process all OpenGL routines
- }
- int main(int argc, char* argv[])
- {
- glutInit(&argc, argv); // Initalise GLUT
- glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // Set display mode
- glutInitWindowPosition(50, 100); // Set window position
- glutInitWindowSize(400, 300); // Set window size
- glutCreateWindow("An Example OpenGL Program"); // Create display window
- init(); // Execute initialisation procedure
- glutDisplayFunc(drawShapes); // Send graphics to display window
- glutMainLoop(); // Display everything and wait
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement