//#include "stdafx.h"
#include<gl/glut.h>
#include<math.h>
#include <stdlib.h>
const double PI = 3.14159265357f;
void myDisplay(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
//红色菱形
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(0.25f, tan(PI / 3) / 4);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(0.0f, tan(PI / 3) / 2);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(-0.25f, tan(PI / 3) / 4);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(0.25f, tan(PI / 3) /4);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(0.75f, tan(PI/3) / 4);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.5f, 0.0f);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(0.5f, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.75f, -tan(PI/3) / 4);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(0.25f, -tan(PI / 3) / 4);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.25f, -tan(PI/3) / 4);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(0.0f, -tan(PI/3) / 2);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(-0.25f, -tan(PI/3) / 4);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(-0.5f, 0.0f);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(-0.75f, -tan(PI/3) / 4);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(-0.25f, -tan(PI / 3) / 4);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 0.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 1.0f); glVertex2f(-0.25f, tan(PI / 3) /4);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(-0.75f, tan(PI/3) / 4);
glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(-0.5f, 0.0f);
glEnd();
glFlush();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(500, 500);
glutCreateWindow("ccz");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}