今天在公司开始了第一天的实习。首先就让学习ray casting算法。
关于ray casting算法的心得我会在学习透彻之后再写一篇文章分析。今天首先做的事情就是配置了OpenGL然后学习了OpenGL配合VS的一些基本使用。
先上代码吧
// openGL_test_d.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "GL/glut.h"
#include "math.h"
using namespace std;
void GL_display()
{
const GLfloat pi = 3.1415926f;
GLfloat a = cos(54 * pi / 180);
GLfloat b = sin(54 * pi / 180);
GLfloat c = cos(18 * pi / 180);
GLfloat d = sin(18 * pi / 180);
GLfloat pointA[2] = {0,1};
GLfloat pointB[2] = { -a, -b };
GLfloat pointC[2] = { c, d };
GLfloat pointD[2] = { -c, d };
GLfloat pointE[2] = { a, -b };
glClear(GL_COLOR_BUFFER_BIT); //用于清除当前的颜色缓冲
glBegin(GL_LINE_LOOP); //设置连线方式位闭曲线
glVertex2fv(pointA);
glVertex2fv(pointB);
glVertex2fv(pointC);
glVertex2fv(pointD);
glVertex2fv(pointE);
glEnd();
glFlush(); //强制刷新缓冲区,让画图程序进行
}
int main(int argc, char *argv[])
{
glut