graphics-04 tree
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdlib.h>
#include<string>
#include<math.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
/*glColor3f(0.298, 0.616, 0.3137);
glLineWidth(4);
glBegin(GL_LINES);
glVertex3f(25,25,0);
glVertex3f(25,75,0);
glEnd();*/
glColor3f(0.0, 0.75, 1.0);
glBegin(GL_POLYGON);
glVertex3f(100,100,0);
glVertex3f(100,80,0);
glVertex3f(0,80,0);
glVertex3f(0,100,0);
glEnd();
glColor3f(0.7,0.8,0.1);
glBegin(GL_POLYGON);
glVertex3f(10,10,0);
glVertex3f(15,10,0);
glVertex3f(15,70,0);
glVertex3f(10,70,0);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(10,10,0);
glVertex3f(15,10,0);
glVertex3f(13,9,0);
glVertex3f(7,5,0);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(15,10,0);
glVertex3f(13,9,0);
glVertex3f(17,4,0);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(5,80,0);
glVertex3f(13,70,0);
glVertex3f(10,70,0);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(15,70,0);
glVertex3f(20,77,0);
glVertex3f(13,70,0);
glEnd();
glutSwapBuffers();
}
void init(void)
{
glClearColor (0.23, 0.8, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (1000, 600);
glutInitWindowPosition (50, 10);
glutCreateWindow ("line and triangle");
glutDisplayFunc(display);
init();
glutMainLoop();
return 0;
}
0 Comments