基础绘制篇
- 点GL_POINTS
- 线GL_LINES
- 线带GL_LINE_STRIP
- 线环GL_LINE_LOOP
- 4个三角面组成的四面体GL_TRIANGLES
- 6个三角面组成的面扇(中心点拔高)GL_TRIANGLE_FAN
- 三角环体GL_TRIANGLE_STRIP
- SpecialKeys函数(控制上下左右键旋转)
- KeyPressFunc函数(空格(ASCII=32)控制模型切换)
- GLMatrixStack
- GLFrame
- GLFrustum
- GLGeometryTransform
#include<GLTools.h>
#include<GLMatrixStack.h>
#include<GLFrame.h>
#include<GLFrustum.h>
#include<GLBatch.h>
#include<GLGeometryTransform.h>
#include<math.h>
#include<GLUT/GLUT.h>
GLShaderManager shaderManager;
GLMatrixStack modelViewMatrix;
GLMatrixStack projectionMatrix;
GLFrame cameraFrame;
GLFrame objectFrame;
GLFrustum viewFrustum;
GLBatch pointBatch;
GLBatch lineBatch;
GLBatch lineStripBatch;
GLBatch lineLoopBatch;
GLBatch triangleBatch;
GLBatch triangleStripBatch;
GLBatch triangleFanBatch;
GLGeometryTransform transformPipeline;
M3DMatrix44f shadowMatrix;
GLfloat vGreen[]={
0.0f,1.0f,0.0f,1.0f};
GLfloat vBlack[]={
0.0f,0.0f,0.0f,1.0f};
int nstep=0;
void SetupRC()
{
glClearColor(0.7f,0.7f,0.7f,1.0f);
shaderManager.InitializeStockShaders();
glEnable(GL_DEPTH_TEST);
transformPipeline.SetMatrixStacks(modelViewMatrix,projectionMatrix);
cameraFrame.MoveForward(-15.0f);
GLfloat vCoast[24][3] = {
{
2.80, 1.20, 0.0 }, {
2.0, 1.20, 0.0 },
{
2.0, 1.08, 0.0 }, {
2.0, 1.08, 0.0 },
{
0.0, 0.80, 0.0 }, {
-.32, 0.40, 0.0 },
{
-.48, 0.2, 0.0 }, {
-.40, 0.0, 0.0 },
{
-.60, -.40, 0.0 }, {
-.80, -.80, 0.0 },
{
-.80, -1.4, 0.0 }, {
-.40, -1.60, 0.0 },
{
0.0, -1.20, 0.0 }, {
.2, -.80, 0.0 },
{
.48, -.40, 0.0 }, {
.52, -.20, 0.0 },
{
.48, .20, 0.0 }, {
.80, .40, 0.0 },
{
1.20, .80