首先
在开始之前,先说一下:如何在Viual Studio (我用的2019)中C++项目中安装OpenGl插件
点击安装即可,全程配置不到20s
使用c++ OpenGL,完成Konx 雪花绘图
#include <GL/glut.h>
#include <stdio.h>
#include <cmath>//这个包用来计算cos、sin角度
#define N 3//图像递归次数
#define C 0.017453//计算cosX角度的一个系数而已
typedef float point[2];
point vertex[3] = { {-0.5,-0.43},{0.5,-0.43},{0,0.43} };//分别是左、右、上三个点
float theta = 0;//初始角度
/*
两点画线函数
*/
void draw_line(point firstPoint, point secondPoint)
{
glBegin(GL_LINES);
glVertex2fv(firstPoint);
glVertex2fv(secondPoint);
glEnd();
}
/*
递归,一分为三,并且确定三点坐标
*/
void divide_line(point fi