Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- void render(void)
- {
- //house
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_POLYGON);
- glColor3f(1, 0, 0);
- glVertex2f(-0.4, 0.4);
- glVertex2f(0.4, 0.4);
- glVertex2f(0.4, -0.4);
- glVertex2f(-0.4, -0.4);
- glEnd();
- //right window
- glBegin(GL_POLYGON);
- glColor3f(0, 0, 1);
- glVertex2f(0.3, 0.3);
- glVertex2f(0.2, 0.3);
- glVertex2f(0.2, 0.2);
- glVertex2f(0.3, 0.2);
- glEnd();
- //left window
- glBegin(GL_POLYGON);
- glColor3f(0, 0, 1);
- glVertex2f(-0.3, 0.3);
- glVertex2f(-0.2, 0.3);
- glVertex2f(-0.2, 0.2);
- glVertex2f(-0.3, 0.2);
- glEnd();
- //door
- glBegin(GL_POLYGON);
- glColor3f(0, 1, 1);
- glVertex2f(-0.1, -0.4);
- glVertex2f(0.1, -0.4);
- glVertex2f(0.1, 0.0);
- glVertex2f(-0.1, 0.0);
- glEnd();
- //path strip 1
- glBegin(GL_POLYGON);
- glColor3f(0, 1, 0);
- glVertex2f(-0.1, -0.4);
- glVertex2f(0.1, -0.4);
- glVertex2f(-0.1, -0.5);
- glVertex2f(-0.3, -0.5);
- glEnd();
- //path strip 2
- glBegin(GL_POLYGON);
- glColor3f(0, 0, 1);
- glVertex2f(-0.3, -0.5);
- glVertex2f(-0.1, -0.5);
- glVertex2f(-0.3, -0.6);
- glVertex2f(-0.5, -0.6);
- glEnd();
- //path strip 3
- glBegin(GL_POLYGON);
- glColor3f(1, 0, 1);
- glVertex2f(-0.5, -0.6);
- glVertex2f(-0.3, -0.6);
- glVertex2f(-0.5, -0.7);
- glVertex2f(-0.7, -0.7);
- glEnd();
- //roof
- glBegin(GL_TRIANGLES);
- glColor3f(0, 1, 0);
- glVertex2f(0.4, 0.4);
- glVertex2f(-0.4, 0.4);
- glVertex2f(0.0, 0.8);
- glEnd();
- glFlush();
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE);
- glutInitWindowSize(1000, 1000);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("House");
- glutDisplayFunc(render);
- glutMainLoop();
- return 0;
- }
Add Comment
Please, Sign In to add comment