自己经常用的一些功能做成了一个模板,有光照效果,可以用鼠标进行缩放,围绕原点旋转坐标系
Main.cpp
#include <GLUT/glut.h>
#include <cstdlib> /* for exit */
#include <vector>
using namespace std;
float zoom = 2000.f;
float rotx = 20;
float roty = 0;
float tx = 0;
float ty = 0;
int lastx=0;
int lasty=0;
unsigned char Buttons[3] = {0};
float lightPosition[] = { -200, 300, 300, 1.0f};
float ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
float diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
float specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
void DrawCoordinate(float _flengthX, float _flengthY, float _flengthZ)
{
glLineWidth(5);
glBegin(GL_LINES);
glColor3f(1,0,0);