#include <iostream>
#include"glut.h"
void display()
{
glClearColor(1, 1, 0.9, 0.3);
glClear(GL_COLOR_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_POLYGON);
glColor3ub(0, 191, 255);
glVertex2f(10, 40);
glVertex2f(15, 65);
glVertex2f(30, 50);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(250, 20, 147);
glVertex2f(15, 65);
glVertex2f(38, 67);
glVertex2f(30, 50);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(250, 20, 147);
glVertex2f(10, 40);
glVertex2f(30, 30);
glVertex2f(30, 50);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(255, 182, 193);
glVertex2f(30, 50);
glVertex2f(50, 60);
glVertex2f(38, 67);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(219, 112, 147);
glVertex2f(30, 50);
glVertex2f(50, 60);
glVertex2f(50, 35);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(218, 112, 214);
glVertex2f(30, 50);
glVertex2f(30, 30);
glVertex2f(50, 35);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(255, 105, 180);
glVertex2f(50, 20);
glVertex2f(30, 30);
glVertex2f(50, 35);
glEnd();
//1
glBegin(GL_POLYGON);
glColor3ub(255, 230, 245);
glVertex2f(50, 20);
glVertex2f(70, 30);
glVertex2f(50, 35);
glEnd();
//2
glBegin(GL_POLYGON);
glColor3ub(218, 112, 214);
glVertex2f(70, 50);
glVertex2f(70, 30);
glVertex2f(50, 35);
glEnd();
//3
glBegin(GL_POLYGON);
glColor3ub(100, 205, 236);
glVertex2f(70, 50);
glVertex2f(50, 60);
glVertex2f(50, 35);
glEnd();
//4
glBegin(GL_POLYGON);
glColor3ub(255, 182, 193);
glVertex2f(70, 50);
glVertex2f(50, 60);
glVertex2f(55, 67);
glEnd();
//5
glBegin(GL_POLYGON);
glColor3ub(250, 20, 147);
glVertex2f(70, 50);
glVertex2f(80, 67);
glVertex2f(55, 67);
glEnd();
//6
glBegin(GL_POLYGON);
glColor3ub(30, 144, 255);
glVertex2f(70, 50);
glVertex2f(80, 67);
glVertex2f(88, 45);
glEnd();
//7
glBegin(GL_POLYGON);
glColor3ub(186, 85, 211);
glVertex2f(70, 30);
glVertex2f(70, 50);
glVertex2f(88, 45);
glEnd();
glPointSize(10);
glBegin(GL_POINTS);
glColor3ub(255, 165, 0);
glVertex2f(75, 20);
glEnd();
glFlush();//显示刷新
}
void init()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 100, 0, 100, -1, 1);
}
void main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//设置初始化的显示模式single单缓冲模式
glutInitWindowSize(500, 500);//窗口大小
glutInitWindowPosition(100, 200);//窗口位置
glutCreateWindow("hello");//创建窗口
init();
glutDisplayFunc(display);//显示的回调,函数指针
glutMainLoop();//刷新效果显示,图形从显存放到内存
system("pause");
}
效果图如下: