Xcode+opengl学习(2)点线面环基本渲染过程

基础绘制篇

  • 点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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值