前言
在整理过去完成的图形学作业时发现了这个作业。当时试着花了五六个旗子,结果现在换了个电脑留下来的就只剩这一个了。。。自己也忘了是哪一国的国旗。这是计算机图形学第二次课的作业,整体也就是画几条边,分几个色块。稍微难一点的是画个五角星。写个rotate函数直接转五次就好。现在把代码贴在下面,希望能给各位同袍们一点帮助。如需转载请标明出处。
代码部分
#include "gl/glut.h"
#include <math.h>
#define NDEBUG
#define PI 3.1415926535898
typedef struct Vector2fDefine
{
GLfloat x;
GLfloat y;
} Vector2f;
void star7(GLfloat centerX, GLfloat centerY, GLfloat endX, GLfloat endY);
void rotate(GLfloat centerX, GLfloat centerY, GLfloat* endX, GLfloat* endY, float rad);
void star7_part(GLfloat centerX, GLfloat centerY, GLfloat endX, GLfloat endY);
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex2f(-0.9, 0.6);
glVertex2f(0.9, 0.6);
glVertex2f(0.9, -0.6);
glVertex2f(-0.9, -0.6);
glEnd();
glColor3f(1, 1, 1)