OpenGl ES---VBO,VAO

网址1:https://learnopengl-cn.github.io/
网址2:https://blog.csdn.net/Kennethdroid/article/details/106844678?spm=1001.2014.3001.5502

VBO,VAO和EBO:
VBO(Vertex Buffer Object):顶点缓冲区对象
VAO(顶点数组对象):顶点数组对象
EBO(Element Buffer Object):元素缓冲对象

起因:
在opengl es编程中,用于绘制的顶点数据首先保存在CPU内存,在调用glDrawArrays和 glDrawElements 等进行绘制时,需要将顶点
数组数据从CPU内存拷贝到显存。我们没有必要每次绘制都去进行内存拷贝,若可以在显存中缓存这些数据,可以降低内存拷贝带来的开销。
所以以上VBO,VAO出现就是为了解决这个问题。
VBO,VAO作用:
在显存中提前开辟好一块内存,用于缓存顶点数据

VBO的创建和更新:

//创建2个VBO
glGenBuffers(2, m_VboIds);
//绑定第一个VBO,拷贝顶点数组到显存
glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//绑定第二个VBO,拷贝图元索引数据到显存
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_VboIds[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

GL_STATIC_DRAW 标志标识缓冲区对象数据被修改一次,使用多次,用于绘制。

实现:使用顶点着色器和片段着色器增加color属性:

//顶点着色器
#version 300 es                            
layout(location = 0) in vec4 a_position;   // 位置变量的属性位置值为 0 
layout(location = 1) in vec3 a_color;      // 颜色变量的属性位置值为 1
out vec3 v_color;                          // 向片段着色器输出一个颜色                          
void main()                                
{                                          
    v_color = a_color;                     
    gl_Position = a_position;              
};

//片段着色器
#version 300 es
precision mediump float;
in vec3 v_color;
out vec4 o_fragColor;
void main()
{
    o_fragColor = vec4(v_color, 1.0);
}

顶点数组数据和图元索引数据:

// 4 vertices, with(x,y,z) ,(r, g, b, a) per-vertex
GLfloat vertices[] =
		{
				-0.5f,  0.5f, 0.0f,       // v0
				1.0f,  0.0f, 0.0f,        // c0
				-0.5f, -0.5f, 0.0f,       // v1
				0.0f,  1.0f, 0.0f,        // c1
				0.5f, -0.5f, 0.0f,        // v2
				0.0f,  0.0f, 1.0f,        // c2
				0.5f,  0.5f, 0.0f,        // v3
				0.5f,  1.0f, 1.0f,        // c3
		};
// Index buffer data
GLushort indices[6] = { 0, 1, 2, 0, 2, 3};

在这里插入图片描述
VBO更新后内存中数据结构:
由于顶点位置和颜色数据在同一个数组里,一起更新到VBO里面,需要知道2个属性的步长和偏移量。
为获得数据队列中下一个属性值,需向右移动6个float,其中3个是位置值,另外3个是颜色值,所以步长
为6float的字节数。
同样,需要指定位置属性和颜色属性在VBO内存中的偏移量,对于每个顶点,位置属性在前,偏移量为0,颜色属性偏移量为
3
sizeof(GLfloat).

使用VBO进行绘制:

glUseProgram(m_ProgramObj);

//不使用 VBO 的绘制
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), vertices);

glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), (vertices + 3));

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);

//使用 VBO 的绘制
glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[0]);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), (const void *)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), (const void *)(3 *sizeof(GLfloat)));

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_VboIds[1]);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (const void *)0);

VAO
顶点数组对象,VAO作用:管理VBO,减少glBindBuffer,glEnableVertexAttribArray,glVertexAttribPointer这些调用操作。
在这里插入图片描述
创建VAO:

// 创建并绑定 VAO
glGenVertexArrays(1, &m_VaoId);
glBindVertexArray(m_VaoId);

// 在绑定 VAO 之后,操作 VBO ,当前 VAO 会记录 VBO 的操作
glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[0]);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), (const void *)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, (3+3)*sizeof(GLfloat), (const void *)(3 *sizeof(GLfloat)));

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_VboIds[1]);

glBindVertexArray(GL_NONE);

使用VAO进行绘制:

// 是不是精简了很多?
glUseProgram(m_ProgramObj);

glBindVertexArray(m_VaoId);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (const void *)0);

实例:实现棋盘格和一系列动点绘制
CoordSystemSample.h代码:



/**
 *
 * Created by 公众号:字节流动 on 2020/4/18.
 * https://github.com/githubhaohao/NDK_OpenGLES_3_0
 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群
 *
 * */

#ifndef NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H
#define NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H


#include "detail/type_mat.hpp"
#include "detail/type_mat4x4.hpp"
#include "GLSampleBase.h"
#include <vector>
#include <map>

#define RENDER_IMG_NUM 3

class CoordSystemSample : public GLSampleBase
{
public:
    CoordSystemSample();

    virtual ~CoordSystemSample();

    virtual void LoadImage(NativeImage *pImage);
    virtual void LoadMultiImageWithIndex(int index, NativeImage *pImage);

    virtual void Init();
    virtual void Draw(int screenW, int screenH);
    virtual void delay(int seconds);

    virtual void Destroy();

    virtual void UpdateTransformMatrix(float rotateX, float rotateY, float scaleX, float scaleY);

    void UpdateMVPMatrix(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio);
    void UpdateMVPMatrix1(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio);
    void UpdateMatrix(glm::mat4 &mvpMatrix, int angleXRotate, int angleYRotate, float scale, glm::vec3 transVec3, float ratio);
    void DrawArray();
    glm::mat4 transform(float height, float dip,float fov_x,float fov_y);
    glm::mat4 buildRotateX(float rad);
    glm::mat4 buildRotateY(float rad);
    glm::mat4 buildRotateZ(float rad);

private:
    GLuint m_TextureId;
    GLint m_SamplerLoc;
    GLint m_SamplerLoc1;
    GLint m_MVPMatLoc;
    GLint m_MVPMatLoc1;
    GLint m_Offset;
    GLint m_MVPMatLoc2;
    GLuint m_VaoId;
    GLuint m_VboIds[3];
    GLuint m_TextureIds[RENDER_IMG_NUM];
    NativeImage m_RenderImages[RENDER_IMG_NUM];
    glm::mat4 m_ModelMatrix;
    std::vector<glm::vec3> windowsTrans;
    std::map<GLfloat, glm::vec3> sorted;
    std::map<int, std::vector<int>>  Map;
    std::vector<int> Vector;
    NativeImage m_RenderImage;
    glm::mat4 m_MVPMatrix;

    int m_AngleX;
    int m_AngleY;
    float m_ScaleX;
    float m_ScaleY;
    float m_FrameIndex;
    float m_Color;
    float m_offset;
    float m_time;
    int m_i;
    CoordSystemSample* m_pCoordSystemSample;

};


#endif //NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H

    
    

CoordSystemSample.cpp代码:

/**
 *
 * Created by 公众号:字节流动 on 2020/4/18.
 * https://github.com/githubhaohao/NDK_OpenGLES_3_0
 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群
 *
 * */

#include "gtc/matrix_transform.hpp"
#include "CoordSystemSample.h"
#include "../util/GLUtils.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <math.h>
#include "../glm/mat4x4.hpp"

#define DRAW_POINTS
#define POINTS_NUM           512
#define POINTS_PRE_TRIANGLES 3
#define TRIANGLES_PER_POINT  3

CoordSystemSample::CoordSystemSample()
{

    m_SamplerLoc = GL_NONE;
    m_MVPMatLoc = GL_NONE;

    m_TextureId = GL_NONE;
    m_VaoId = GL_NONE;

    m_AngleX = 0;
    m_AngleY = 0;

    m_ScaleX = 1.0f;
    m_ScaleY = 1.0f;

    m_offset=0.0f;
    m_i=0;

    //m_pCoordSystemSample = new CoordSystemSample();
}

CoordSystemSample::~CoordSystemSample()
{
    NativeImageUtil::FreeNativeImage(&m_RenderImage);

}

void CoordSystemSample::Init()
{
    if(m_ProgramObj != 0)
        return;
    //顶点着色器
    char vShaderStr[] =
            "#version 300 es                          \n"  //着色器版本
            "layout(location = 0) in vec3 vPosition;  \n"  //声明输入属性数组 名为vPosition的四分量
            "layout(location = 1) in vec3 aColor;  \n"
            "out vec4 vertexColor;  \n"
            "uniform mat4 u_MVPMatrix;\n"
            "void main()                              \n"  //声明main,表示着色器执行开始
            "{                                        \n"
            "   gl_Position = u_MVPMatrix * vec4(vPosition,1.0);\n" //将输入属性(vPosition*u_MVPMatrix)赋值给gl_Position的特殊输出变量
            "   vertexColor = vec4( aColor, 1.0);              \n"
            "}                                        \n"; //每个顶点着色器必须在gl_Position变量中输出一个位置;这个变量定义传递到管线下一个阶段的位置

    char vShaderStr1[] =
            "#version 300 es                          \n"  //着色器版本
            "layout(location = 2) in float p_tData_z;\n"
            "layout(location = 3) in float p_tData_x;\n"
            "uniform mat4 u_MVPMatrix1;\n"
            "uniform float u_offset;\n"
            "void main()                              \n"  //声明main,表示着色器执行开始
            "{                                        \n"
            "    vec4 pos;\n"
            "    pos.w = 1.0;\n"
            "    pos.y = 0.0;\n"
            "    pos.xz = vec2(p_tData_x, p_tData_z+u_offset);\n"
            "    gl_PointSize = 20.0;\n"
            "    gl_Position = u_MVPMatrix1 * pos;\n"
            "}                                        \n"; //每个顶点着色器必须在gl_Position变量中输出一个位置;这个变量定义传递到管线下一个阶段的位置
    "}";
    //片段着色器
    char fShaderStr[] =
            "#version 300 es                              \n"  //着色版本
            "precision mediump float;                     \n"  //声明着色器中浮点数的默认精度
            "in vec4 vertexColor;                          \n"
            "out vec4 fragColor;                          \n"  //一个4分量的输出变量 写入这个变量的值将被输出到颜色缓存区
            "void main()                                  \n"
            "{                                            \n"
            "   fragColor = vertexColor;  \n"  //所有片段的着色器输出颜色为红色
            "}                                            \n";

    char fShaderStr1[] =
            "#version 300 es\n"
            "precision mediump float;\n"
            "out vec4 fragColor;                          \n"  //一个4分量的输出变量 写入这个变量的值将被输出到颜色缓存区
            "uniform vec4 u_Color;\n"
            "void main()\n"
            "{\n"
            "    //outColor = texture(s_TextureMap, v_texCoord);\n"
            "    fragColor = u_Color;\n"
            "}";

    m_ProgramObj = GLUtils::CreateProgram(vShaderStr, fShaderStr, m_VertexShader, m_FragmentShader); //创建着色器程序
    m_MVPMatLoc = glGetUniformLocation(m_ProgramObj, "u_MVPMatrix");  //返回统一变量的位置
    m_ProgramObj1 = GLUtils::CreateProgram(vShaderStr1, fShaderStr1, m_VertexShader1, m_FragmentShader1); //创建着色器程序
    m_MVPMatLoc1 = glGetUniformLocation(m_ProgramObj1, "u_MVPMatrix1");  //返回统一变量的位置
};

void CoordSystemSample::LoadImage(NativeImage *pImage)
{
#if 0
    LOGCATE("CoordSystemSample::LoadImage pImage = %p", pImage->ppPlane[0]);
	if (pImage)
	{
		m_RenderImage.width = pImage->width;
		m_RenderImage.height = pImage->height;
		m_RenderImage.format = pImage->format;
		NativeImageUtil::CopyNativeImage(pImage, &m_RenderImage);
	}
#endif
}
void CoordSystemSample::LoadMultiImageWithIndex(int index, NativeImage *pImage)
{
    GLSampleBase::LoadMultiImageWithIndex(index, pImage);
    LOGCATE("BlendingSample::LoadImage index=%d, pImage = %p", index, pImage->ppPlane[0]);
    if (pImage)
    {
        m_RenderImages[index].width = pImage->width;
        m_RenderImages[index].height = pImage->height;
        m_RenderImages[index].format = pImage->format;
        NativeImageUtil::CopyNativeImage(pImage, &m_RenderImages[index]);
    }
}
void CoordSystemSample::DrawArray() {
#ifdef DRAW_POINTS
    glDrawArrays(GL_LINES, 0, POINTS_NUM * TRIANGLES_PER_POINT);
#else
    glDrawArrays(GL_TRIANGLES, 0, POINTS_NUM * POINTS_PRE_TRIANGLES);
    glDrawArrays(GL_LINES, 0, POINTS_NUM * POINTS_PRE_TRIANGLES);
#endif
}
glm::mat4 CoordSystemSample::transform(float height, float dip,float fov_x,float fov_y)
{
    float distance= height/(tan(glm::radians(dip)));
    float radiansY=0.0;
    float radiansZ=0.0;
    LOGCATD("distance = %f",distance);
    //glm::mat4 Projection = glm::frustum(-0.699f, 0.699f, -0.3934f, 0.3934f, imagez, 100.0f);
    // glm::mat4 Projection = glm::perspective(glm::radians(fov_y), fov_x/fov_y,2.0f,200.0f); //描绘的是屏幕  任务:加一个横向fov 算出来高宽比
    glm::mat4 Projection = glm::perspective(glm::radians(4.0f), fov_x/fov_y,0.1f, 200.f);
    LOGCATD("aspect = %f",fov_x/fov_y);
    //透视投影矩阵 第1个参数为视锥上下面之间的夹角 第2个参数为宽高比  第3,第4分别为近界面和远界面的深度
    //glm::mat4 Projection = glm::pers pective(10.0f,854.0f/480.0f, imagez,100.0f);

    //摄像机位置:世界空间中一个指向摄像机位置的向量(即摄像机位置)
    glm::vec3 cameraPos = glm::vec3(-0.37, height, 1.31834);
    //摄像机方向:摄像机指向哪个方向(即中心坐标)
    glm::vec3 cameraTarget = glm::vec3(-0.37f+distance*sin(glm::radians(0.0)), 0.0f, -distance*cos(glm::radians(0.0))+1.31834);
    glm::vec3 cameraDirection = glm::normalize(cameraPos - cameraTarget);
    LOGCATD("cameraDirection[0]:%f,cameraDirection[1]:%f,cameraDirection[2]:%f,",cameraDirection[0],cameraDirection[1],cameraDirection[2]);
    //glm::vec3 right = glm::vec3(1.0f, 0.0f, 0.0f); //右向量
    //glm::vec3 right = glm::vec3(cos(glm::radians(0.0)), sin(glm::radians(0.0)), 0.0f); //右向量 上下
    glm::vec3 right = glm::vec3(cos(glm::radians(0.0)), 0.0, sin(glm::radians(0.0))); //右向量 水平倾角
    //glm::vec4 right_trans=glm::vec4(1.0f, 0.0f, 0.0f,1.0);
    glm::vec3 cameraUp = glm::normalize(glm::cross(cameraDirection,right ));
    LOGCATD("cameraUp[0]:%f,cameraUp[1]:%f,cameraUp[2]:%f,",cameraUp[0],cameraUp[1],cameraUp[2]);
    //glm::vec3 cameraUp = glm::normalize(glm::cross(cameraDirection, cameraRight));
    glm::mat4 View = glm::lookAt(
            //glm::vec3(-0.087f, 0.380198f, 0.311671f), // Camera is at (0,0,1), in World Space  0.35628f
            cameraPos,
            //glm::vec3(0, 0, -distance), // and looks at the origin
            cameraTarget,
            cameraUp
            //glm::vec3(-tan(glm::radians(0.0f)), 1.0f, 0)  // Head is up (set to 0,-1,0 to look upside-down)
    ); //描绘的是人眼
    //将顶点的世界空间坐标装换为观察空间坐标
    //glm::lookAt函数有三个参数,eye表示摄像机所在的位置,center表示摄像机要看向的中心点的位置,up表示摄像机的三个方位向量中的up向量
    glm::mat4 Model = glm::mat4(1.0f);
    //LOGCATD("XXCC Model = %f",Model[0][0]);
    Model = glm::scale(Model, glm::vec3(1.0, 1.0, 1.0f)); //用于对物体进行缩放
    //Model = glm::rotate(Model, 1, glm::vec3(1.0f, 0.0f, 0.0f));
    //Model = glm::rotate(Model, 1, glm::vec3(0.0f, 1.0f, 0.0f));
    //Model = glm::rotate(Model, glm::radians(5.0f), glm::vec3(0.0f, 0.0f, 1.0f));
    Model = glm::translate(Model, glm::vec3(0.0f, 0.0f, 0.0f)); //用于对物体进行位移

    m_MVPMatrix = Projection * View;
    /*LOGCATE("XXCCCC2: {%f, %f, %f, %f;  %f, %f, %f, %f;  %f, %f, %f, %f;  %f, %f, %f, %f}",
            m_MVPMatrix[0][0],m_MVPMatrix[0][1],m_MVPMatrix[0][2],m_MVPMatrix[0][3],
            m_MVPMatrix[1][0],m_MVPMatrix[1][1],m_MVPMatrix[1][2],m_MVPMatrix[1][3],
            m_MVPMatrix[2][0],m_MVPMatrix[2][1],m_MVPMatrix[2][2],m_MVPMatrix[2][3],
            m_MVPMatrix[3][0],m_MVPMatrix[3][1],m_MVPMatrix[3][2],m_MVPMatrix[3][3]);*/
    return m_MVPMatrix = Projection * View * Model;       //* buildRotateY(glm::radians(0.0)) * buildRotateZ(glm::radians(2.0));
}
void CoordSystemSample::delay(int seconds)
{
    clock_t start = clock();
    clock_t lay = (clock_t)seconds * CLOCKS_PER_SEC;
    while ((clock()-start) < lay);
}

void CoordSystemSample::Draw(int screenW, int screenH)
{
    float degree = 0.0f;
    //float degree = 5.2f;
    //LOGCATE("TriangleSample::Draw");
    float imagey_clib = 0.5f;

    float imagez = 7.8f;
    float fovx_clib = 10.0f;
    float fovx = 10.0f;
    //fovx_clib / 440.f * 480.f;
    float aspect = 854.0f/480.0f;
    float halfimagewidth = imagez * tan(glm::radians(fovx/2))-0.16;
    float halfimageheight = halfimagewidth / aspect;
    //float imagey = imagey_clib - 55.0f/480.f * halfimageheight;
    // float imagey = 1.3296f - 0.35628f;
    float imagey =0.0f;
    GLfloat vVertices[] = {  //顶点数据
            1.2f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,0,0,//红色代表:最右端
            1.2f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,0,0,
            0.4f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,1,1, //白色代表:
            0.4f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,1,1,
            -0.37f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),0,1,0, //绿色代表:
            -0.37f, -imagey, -120.0f / abs(cos(glm::radians(degree))),0,1,0,
            -1.0f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,1,1, //白色代表:
            -1.0f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,1,1,
            -2.0f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,0,0, //红色代表:最左端
            -2.0f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,0,0,
            2.0f, -imagey, -85.0f / abs(cos(glm::radians(degree))),1,1,0, //黄色代表(最上端):
            -2.0f, -imagey, -85.0f / abs(cos(glm::radians(degree))),1,1,0,
            2.0f, -imagey, -30.0f / abs(cos(glm::radians(degree))),0,1,1, //青色代表(中):
            -2.0f, -imagey, -30.0f / abs(cos(glm::radians(degree))),0,1,1,

            //2.0f, -imagey, -16.70771550640865f / abs(cos(glm::radians(degree))),0,1,0,
            //-2.0f, -imagey, -16.70771550640865f / abs(cos(glm::radians(degree))),0,1,0,
            2.0f, -imagey, -13.5f / abs(cos(glm::radians(degree))),0,1,0,
            -2.0f, -imagey, -13.5f / abs(cos(glm::radians(degree))),0,1,0,

    };

    if(m_ProgramObj == 0)
        return;

    float dip=2.5f; //倾角
    float height = 1.326f; //摄像机高度
    float fov_x=10.0; //横向fov
    float fov_y=4.0; //纵向fov
    glm::mat4 m_MVPMatrix=transform(height, dip,fov_x,fov_y);
    glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清除模板缓冲 颜色缓冲 深度缓冲
    glClearColor(0.0, 0.0, 0.0, 1.0);   //用于设置背景色
    //glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    // Use the program object
    glUseProgram (m_ProgramObj); //激活着色器
    glUniformMatrix4fv(m_MVPMatLoc, 1, GL_FALSE, &m_MVPMatrix[0][0]); //通过一致变量引用将一致变量值传入渲染管线
    // Load the vertex data
    glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); //更新顶点格式
    glEnableVertexAttribArray (0); //启用指定属性 可在顶点着色器中访问逐顶点的属性数据(即允许着色器读取GPU数据)

    unsigned int VBO, VAO;
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
    glBindVertexArray(VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vVertices), vVertices, GL_STREAM_DRAW);
    // 位置属性
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);
    // 颜色属性
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3* sizeof(float)));
    glEnableVertexAttribArray(1);
    //GL_LINE_STRIP GL_LINES
    glLineWidth(10);  //线条的栅格化宽度
    //glEnable(GL_LINE_SMOOTH);
    glDrawArrays (GL_LINES, 0, 36); //画直线

    // int tDataSize = POINTS_NUM * POINTS_PRE_TRIANGLES;
    //float *p_tData = new float[tDataSize];
    //GLfloat p_tData[] ={-2.0,-1.9,-1.8,-1.5,-1.2,-1.0,-0.8,-0.5,-0.37,0.0,0.2,0.4,0.6,0.8,1.2};
    /* GLfloat p_tData_z[1024]={-13.0,-14.0,-16.0,-18.0,-19.0,-20.0,-21.0,-22.0,-23.0,-24.0,-25.0,-28.0,-30.0,-35.0,-40.0};
     GLfloat p_tData_x[1024]={-2.0,-1.9,-1.8,-1.5,-1.2,-1.0,-0.8,-0.5,-0.37,0.0,0.2,0.4,0.6,0.8,1.2};
     GLuint m_VboIds[2];
     glUseProgram(m_ProgramObj1);
     glUniformMatrix4fv(m_MVPMatLoc1, 1, GL_FALSE, &m_MVPMatrix[0][0]); //通过一致变量引用将一致变量值传入渲染管线
     GLUtils::setVec4(m_ProgramObj1, "u_Color", glm::vec4(0.0f, 1.0f, 1.0f, 1.0f));
     glGenVertexArrays(1, &VAO);
     glGenBuffers(2, m_VboIds);
     // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
     glBindVertexArray(VAO);

     glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[0]);
     glBufferData(GL_ARRAY_BUFFER, sizeof(p_tData_z) ,  p_tData_z, GL_STATIC_DRAW);
     // 位置属性
     glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), (void*)0);
     glEnableVertexAttribArray(2);

     glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[1]);
     glBufferData(GL_ARRAY_BUFFER, sizeof(p_tData_x) ,  p_tData_x, GL_STATIC_DRAW);
     // 位置属性
     glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), (void*)0);
     glEnableVertexAttribArray(3);*/
    // GLfloat p_tData[1024]={-2.0,-13.0,-1.9,-14.0,-1.8,-16.0,-1.5,-18.0,-1.2,-19.0,-1.0,-20.0,-0.8,-21.0,-0.5,-22.0,-0.37,-23.0,0.0,-24.0,0.2,-25.0,0.4,-28.0,0.6,-30.0,0.8,-35.0,1.2,-40.0};
    GLfloat p_tData[10][200]={{-2.168064710585829, -4.786828947528996, -2.1595033603895164, -5.003244522349575, -2.1480500073589957, -5.222606301774769, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.1151137914646543, -6.743350373943072, -2.089940584405955, -7.146851586541547, -2.0906566999787635, -7.600914934304177, -2.071231737458623, -8.159734113598189, -2.0454397762986036, -8.756416627618139, -2.0339469749881873, -9.44783549412571, -2.013837504834276, -10.324547817010957, -1.9754179299954777, -11.298606801812854, -1.9527304195994724, -12.473452033339026, -1.915446880798522, -14.048038135668069, -1.8327722308945662, -15.90947153403217, -1.7956345806666794, -18.34175760037252, -1.685050938811831, -21.950682715419084, -1.520377510848388, -26.86080355929723, -1.326849060242521, -34.584044120003384, -0.9126497220349112, -50.09183138183028, 2.593669136574661E-6, -85.86069395120855, 2.14038741066906, -4.786828948834825, 2.1305819759884645, -5.003244486039925, 2.1329588070271157, -5.222606225513782, 2.1143945139015643, -5.461670462730262, 2.124051095659115, -5.745150828795599, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 2.00670735645765, -9.447835013675586, 2.0039177193129576, -10.324548611608883, 1.9645643861488278, -11.298606686546204, 1.9167911573591778, -12.473452315033478, 1.9019588347176697, -14.04803888583478, 1.8327731846147466, -15.909473239919436, 1.7780314959972423, -18.341756142341005, 1.6850522033031978, -21.95068214685878, 1.5719172072866336, -26.860803676950383, 1.3268512389760134, -34.58404534596737, 0.8646185338698238, -50.091830941049814, 2.593669136574661E-6, -85.86069395120855},
                               {-2.2049678156514023, -4.786829078782961, -2.198066025176287, -5.00324466686155, -2.188294625614369, -5.222605905348471, -2.182770015897539, -5.461670620679042, -2.173832948520706, -5.745150796939978, -2.161193649917144, -6.035502145549806, -2.147354208956651, -6.357028025276187, -2.147554022042002, -6.743351054723037, -2.131189353407843, -7.146851885468177, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0435988641635556, -10.324548045529285, -2.0079797182261108, -11.298607045825198, -1.9886703637482839, -12.473451102906733, -1.955914185958793, -14.048038435968497, -1.8785914806843345, -15.909471868146126, -1.8484475395596232, -18.341756227181293, -1.748240543078457, -21.950683189215088, -1.5976847588788912, -26.860804140071018, -1.4263629378619451, -34.58404151521079, -0.24694554594121976, -85.86069581467021, 2.1034840821165393, -4.786829083779365, 2.092019549587771, -5.003244626615285, 2.0876835599237573, -5.222606041191612, 2.07231703556208, -5.46167061647896, 2.0742684469654376, -5.745151217733758, 2.0566199487800603, -6.035502069428346, 2.0494695919295793, -6.357027530797484, 2.037257156748324, -6.743350987825565, 2.0280679205219165, -7.146852045500597, 2.017557058403818, -7.600914754724766, 2.000622039004057, -8.159733531554625, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8688714088399083, -12.473451866370922, 1.8210243656520189, -14.048038113009271, 1.7869537942541998, -15.909470476490615, 1.6724059206176967, -18.341755178687325, 1.6218627331287405, -21.950682618440435, 1.443071729804439, -26.86080377164454, 1.2273374209531085, -34.584042740190625, -0.24694554594121976, -85.86069581467021},
                               {-2.200354825814602, -4.7868293550347785, -2.198066025176287, -5.00324466686155, -2.1832642262950763, -5.222606233549631, -2.1775104948623114, -5.461670950663911, -2.173832948520706, -5.745150796939978, -2.1553838973750796, -6.035501913850994, -2.1412364524450984, -6.357027774404684, -2.134577999795926, -6.743350515309284, -2.1243144291067497, -7.146852305443537, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0535191382013136, -10.324548436679715, -2.018833709766037, -11.298606373093529, -1.9766903758043213, -12.47345181036096, -1.9828922328896987, -14.048038186488464, -1.9244109236707134, -15.90947223525684, -1.8660518496043061, -18.341756951612545, -1.8324929848455822, -21.950682394162374, -1.7265304002515136, -26.860804237471598, -1.5590478620451187, -34.584043611886166, -0.7802191759798485, -81.38057409088681, 2.1034840821165393, -4.786829083779365, 2.0968397009440976, -5.003244432714191, 2.092714069578704, -5.22260583105579, 2.0828361814343674, -5.461671244928169, 2.0797997776919006, -5.745150963795188, 2.074049051865287, -6.035501943205265, 2.0617052637855213, -6.357027622559288, 2.0567215289700247, -6.743350843752931, 2.0418175785246984, -7.146852173245545, 2.0248669647953075, -7.6009144297536695, 2.008467549264596, -8.159733989291261, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.725861405495664, -15.90947145941073, 1.6548016400976284, -18.341757691014156, 1.516547116812408, -21.95068270616467, 1.2884569376475334, -26.86080234492618, 0.995138679239107, -34.58404226088751, -0.7802191759798485, -81.38057409088681},
                               {-2.200354825814602, -4.7868293550347785, -2.198066025176287, -5.00324466686155, -2.188294625614369, -5.222605905348471, -2.1775104948623114, -5.461670950663911, -2.173832948520706, -5.745150796939978, -2.1553838973750796, -6.035501913850994, -2.1412364524450984, -6.357027774404684, -2.134577999795926, -6.743350515309284, -2.1243144291067497, -7.146852305443537, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0535191382013136, -10.324548436679715, -2.018833709766037, -11.298606373093529, -1.9766903758043213, -12.47345181036096, -1.9828922328896987, -14.048038186488464, -1.9244109236707134, -15.90947223525684, -1.8660518496043061, -18.341756951612545, -1.8114300132529146, -21.95068366079674, -1.7265304002515136, -26.860804237471598, -1.5258764812771153, -34.58404561133605, -0.7021969799202927, -81.38057875299079, 2.1034840821165393, -4.786829083779365, 2.0968397009440976, -5.003244432714191, 2.092714069578704, -5.22260583105579, 2.0828361814343674, -5.461671244928169, 2.0797997776919006, -5.745150963795188, 2.074049051865287, -6.035501943205265, 2.0617052637855213, -6.357027622559288, 2.0567215289700247, -6.743350843752931, 2.0349426542236055, -7.146851753270186, 2.0248669647953075, -7.6009144297536695, 2.008467549264596, -8.159733989291261, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.725861405495664, -15.90947145941073, 1.6548016400976284, -18.341757691014156, 1.516547116812408, -21.95068270616467, 1.3142259995291141, -26.860803900319613, 0.995138679239107, -34.58404226088751, -0.7021969799202927, -81.38057875299079},
                               {-2.1772904291009914, -4.78682886761486, -2.1691441477475553, -5.003244441252837, -2.1530806450643656, -5.222605977510224, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.0237580321572413, -10.324548212344043, -1.9971257602842378, -11.298606586469038, -1.9766903758043213, -12.47345181036096, -1.955914185958793, -14.048038435968497, -1.909137784701946, -15.909471586450682, -1.883655965686657, -18.341755884457637, -1.8324929848455822, -21.950682394162374, -1.7265304002515136, -26.860804237471598, -1.6253903588965395, -34.58404300654346, -1.4410266914979077, -50.09183374703773, -0.9877894613991656, -85.8606930807611, 2.1311614760481037, -4.786829319585159, 2.1257615783728294, -5.003244207105479, 2.1228976513014914, -5.222605604814643, 2.1143945139015643, -5.461670462730262, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 1.9976271006891144, -9.447835393059018, 1.984076870083951, -10.324547401855037, 1.942856437159106, -11.298606502968957, 1.8808513771007946, -12.473451381894762, 1.8480024130750015, -14.04803839228756, 1.7564076201184968, -15.909471742582403, 1.6724059206176967, -18.341755178687325, 1.5376103416902833, -21.95068396861638, 1.365764438963244, -26.86080175996974, 0.995138679239107, -34.58404226088751, 0.38427571448675657, -50.09183132922181, -0.9877894613991656, -85.8606930807611},
                               {-2.1772904291009914, -4.78682886761486, -2.1691441477475553, -5.003244441252837, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.033678320602052, -10.32454863353877, -1.9971257602842378, -11.298606586469038, -1.9886703637482839, -12.473451102906733, -1.969403280297729, -14.048038983042536, -1.9244109236707134, -15.90947223525684, -1.9012604843191583, -18.341756612333423, -1.8746190955579194, -21.95068415577966, -1.8038378549831373, -26.86080222850322, -1.7249039574243241, -34.58404376526364, -1.5370952203655257, -50.09183287625094, -1.234737332825185, -85.86069493979406, 2.1265484867033804, -4.7868290731316, 2.1257615783728294, -5.003244207105479, 2.1228976513014914, -5.222605604814643, 2.1091347489305905, -5.46167070309498, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.984076870083951, -10.324547401855037, 1.9320024638260258, -11.298606932772895, 1.8688714088399083, -12.473451866370922, 1.8345134826264935, -14.048038936655178, 1.741134480657652, -15.909472361590304, 1.6371974197213688, -18.341756625581517, 1.4954839268719944, -21.950683559389393, 1.2884569376475334, -26.86080234492618, 0.9287961073999602, -34.584041626976735, 0.2882071404296722, -50.09183042937489, -1.234737332825185, -85.86069493979406},
                               {-2.181903172678483, -4.786829064198581, -2.1691441477475553, -5.003244441252837, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.033678320602052, -10.32454863353877, -2.0079797182261108, -11.298607045825198, -2.0006503320091698, -12.473451587382893, -1.9828922328896987, -14.048038186488464, -1.9549570191005075, -15.909471950116858, -1.936468686467168, -18.341756295717452, -1.8956823204357942, -21.950682893327944, -1.8553760844348286, -26.860801742423593, -1.791246871943457, -34.58404313701175, -1.6811983673910635, -50.091829101982015, -1.481685472435541, -85.86069680325572, 2.1265484867033804, -4.7868290731316, 2.1209413078234642, -5.00324440297488, 2.1228976513014914, -5.222605604814643, 2.1091347489305905, -5.46167070309498, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.9741564940758467, -10.324548837912864, 1.9211486399763213, -11.298607389914709, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.7105882558380265, -15.909470558461345, 1.6195930801520704, -18.341755562117186, 1.4744208365783646, -21.950682324521598, 1.23691884089339, -26.860804479617173, 0.8292823747800069, -34.58404238791125, 0.1441043715952689, -50.091831507301514, -1.481685472435541, -85.86069680325572},
                               {-2.181903172678483, -4.786829064198581, -2.1739645374899594, -5.003244639090546, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.033678320602052, -10.32454863353877, -2.0079797182261108, -11.298607045825198, -2.0006503320091698, -12.473451587382893, -1.9963813272286348, -14.048038733562503, -1.9702301841493521, -15.909471019615255, -1.9540732050996692, -18.341757023593242, -1.937808735254083, -21.95068248410096, -1.906914270583751, -26.860803878590815, -1.8575891602070602, -34.5840425282245, -1.8253007431352026, -50.09183503185817, -1.728633496542227, -85.86069031902201, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.9741564940758467, -10.324548837912864, 1.9211486399763213, -11.298607389914709, 1.8449114526350596, -12.473451643392858, 1.794046333620243, -14.048037863283199, 1.6953152313599609, -15.909472725502518, 1.5843844749618334, -18.341757010733648, 1.432294481356595, -21.95068191431046, 1.1853804326521407, -26.860803996490006, 0.7629399032429413, -34.58404512046571, 1.5436564230197902E-6, -50.091832616010564, -1.728633496542227, -85.86069031902201},
                               {-2.181903172678483, -4.786829064198581, -2.1739645374899594, -5.003244639090546, -2.1631419260247746, -5.222605895394106, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.0435988641635556, -10.324548045529285, -2.0079797182261108, -11.298607045825198, -2.0126301507866806, -12.473452099196928, -2.0098702649214744, -14.048037936762393, -1.9855035168068071, -15.909471671619913, -1.9892816163275735, -18.341756680623543, -1.9799348813959579, -21.950682100243544, -1.958452514934572, -26.86080339275722, -1.9239318656462987, -34.58404192632633, -1.9694040540511688, -50.09183126029566, -1.9755813828673763, -85.86069217830101, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9794668126389905, -9.447836148135304, 1.9741564940758467, -10.324548837912864, 1.9102946489284724, -11.298606746981301, 1.8449114526350596, -12.473451643392858, 1.7805572397733835, -14.048038440155496, 1.6800420663111166, -15.909471795000915, 1.56678017981628, -18.34175773491886, 1.3901682360600127, -21.950683648343826, 1.1338422032004494, -26.860803510410378, 0.6634261001191663, -34.58404251444293, -0.0960671495937, -50.091831718131935, -1.9755813828673763, -85.86069217830101},
                               {-2.186516386002231, -4.786828791637338, -2.1739645374899594, -5.003244639090546, -2.1631419260247746, -5.222605895394106, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.0435988641635556, -10.324548045529285, -2.018833709766037, -11.298606373093529, -2.0126301507866806, -12.473452099196928, -2.023359359260411, -14.048038483836432, -2.000776268890276, -15.909472284230814, -2.0068859263722567, -18.341757405054796, -2.000998339520709, -21.950682957896962, -2.0099907443862635, -26.86080290667759, -1.9902742924859744, -34.58404465814267, -2.0654725829187868, -50.09183038950887, -2.2225297752708633, -85.8606940757436, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9794668126389905, -9.447836148135304, 1.964236069215305, -10.324548218136812, 1.9102946489284724, -11.298606746981301, 1.8329316136823954, -12.473450933478246, 1.7805572397733835, -14.048038440155496, 1.6647688123595703, -15.909470895773802, 1.5491759450329674, -18.34175669953052, 1.3691051807038443, -21.95068452915246, 1.082303973748758, -26.860803024330746, 0.5970836032677456, -34.584041909100215, -0.19213567895339512, -50.091830817546885, -2.2225297752708633, -85.8606940757436}};

   // GLfloat p_tData[1024]={-2.168064710585829, -4.786828947528996, -2.1595033603895164, -5.003244522349575, -2.1480500073589957, -5.222606301774769, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.1151137914646543, -6.743350373943072, -2.089940584405955, -7.146851586541547, -2.0906566999787635, -7.600914934304177, -2.071231737458623, -8.159734113598189, -2.0454397762986036, -8.756416627618139, -2.0339469749881873, -9.44783549412571, -2.013837504834276, -10.324547817010957, -1.9754179299954777, -11.298606801812854, -1.9527304195994724, -12.473452033339026, -1.915446880798522, -14.048038135668069, -1.8327722308945662, -15.90947153403217, -1.7956345806666794, -18.34175760037252, -1.685050938811831, -21.950682715419084, -1.520377510848388, -26.86080355929723, -1.326849060242521, -34.584044120003384, -0.9126497220349112, -50.09183138183028, 2.593669136574661E-6, -85.86069395120855, 2.14038741066906, -4.786828948834825, 2.1305819759884645, -5.003244486039925, 2.1329588070271157, -5.222606225513782, 2.1143945139015643, -5.461670462730262, 2.124051095659115, -5.745150828795599, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 2.00670735645765, -9.447835013675586, 2.0039177193129576, -10.324548611608883, 1.9645643861488278, -11.298606686546204, 1.9167911573591778, -12.473452315033478, 1.9019588347176697, -14.04803888583478, 1.8327731846147466, -15.909473239919436, 1.7780314959972423, -18.341756142341005, 1.6850522033031978, -21.95068214685878, 1.5719172072866336, -26.860803676950383, 1.3268512389760134, -34.58404534596737, 0.8646185338698238, -50.091830941049814, 2.593669136574661E-6, -85.86069395120855};

   for(int j=0,m=0;j<10;j++)
   {
       while (p_tData[j][m]!=0)
       {
           m++;
       }
       LOGCATE("m=%d",m);
      for(int i=0;i<m/2;i=i+2)
      {
          p_tData[j][m+i]=(p_tData[j][i]+p_tData[j][m/2+i])/2.0;
          p_tData[j][m+i+1]=(p_tData[j][i+1]+p_tData[j][m/2+i+1])/2.0;
      }
       LOGCATE("p_tData[0][0]=%f",p_tData[0][0]);
       LOGCATE("p_tData[0][48]=%f",p_tData[0][48]);
       LOGCATE("p_tData[0][96]=%f",p_tData[0][96]);
       LOGCATE("p_tData[0][1]=%f",p_tData[0][1]);
       LOGCATE("p_tData[0][49]=%f",p_tData[0][49]);
       LOGCATE("p_tData[0][97]=%f",p_tData[0][97]);
      m=0;
   }
    glUseProgram(m_ProgramObj1);
    glUniformMatrix4fv(m_MVPMatLoc1, 1, GL_FALSE, &m_MVPMatrix[0][0]); //通过一致变量引用将一致变量值传入渲染管线
    GLUtils::setVec4(m_ProgramObj1, "u_Color", glm::vec4(0.0f, 1.0f, 1.0f, 1.0f));
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
    glBindVertexArray(VAO);
    m_i++;
    if(m_i>9)
        m_i=0;
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(p_tData[m_i]), p_tData[m_i], GL_STREAM_DRAW);
    LOGCATE("p_tData[m_i]=%d",sizeof(p_tData[m_i]));
    // 位置属性
    glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(3);
    // 颜色属性
    glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)(1* sizeof(float)));
    glEnableVertexAttribArray(2);
    //GL_LINE_STRIP GL_LINES

    if (m_ProgramObj1 == GL_NONE) return;
    // Use the program object
    glEnable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
    glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Screen blend mode
    glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
    m_offset=0.0f;
    GLUtils::setFloat(m_ProgramObj1, "u_offset", m_offset);
    glDrawArrays (GL_POINTS, 0, 200);
    //DrawArray();
    delay(1);
}

void CoordSystemSample::Destroy()
{
    if (m_ProgramObj)
    {
        glDeleteProgram(m_ProgramObj);
        m_ProgramObj = GL_NONE;
    }
    if (m_ProgramObj1)
    {
        glDeleteProgram(m_ProgramObj1);
        m_ProgramObj1 = GL_NONE;
    }
}


/**
 * @param angleX 绕X轴旋转度数
 * @param angleY 绕Y轴旋转度数
 * @param ratio 宽高比
 * */
glm::mat4 CoordSystemSample::buildRotateX(float rad)
{
    glm::mat4 xrot = glm::mat4(1.0, 0.0, 0.0, 0.0,
                               0.0, cos(rad), -sin(rad), 0.0,
                               0.0, sin(rad), cos(rad), 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return xrot;
}
glm::mat4 CoordSystemSample::buildRotateY(float rad)
{
    glm::mat4 yrot = glm::mat4(cos(rad), 0.0, sin(rad), 0.0,
                               0.0, 1.0, 0.0, 0.0,
                               -sin(rad), 0.0, cos(rad), 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return yrot;
}
glm::mat4 CoordSystemSample::buildRotateZ(float rad)
{
    glm::mat4 zrot = glm::mat4(cos(rad), -sin(rad), 0.0, 0.0,
                               sin(rad), cos(rad), 0.0, 0.0,
                               0.0, 0.0, 1.0, 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return zrot;
}
float distance_z = -0.2f;
void CoordSystemSample::UpdateMVPMatrix(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio)
{

}

void CoordSystemSample::UpdateTransformMatrix(float rotateX, float rotateY, float scaleX, float scaleY)
{

}


结果:
在这里插入图片描述
贝塞尔曲线
CoordSystemSample.h代码:


/**
 *
 * Created by 公众号:字节流动 on 2020/4/18.
 * https://github.com/githubhaohao/NDK_OpenGLES_3_0
 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群
 *
 * */

#ifndef NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H
#define NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H


#include "detail/type_mat.hpp"
#include "detail/type_mat4x4.hpp"
#include "GLSampleBase.h"
#include <vector>
#include <map>

#define RENDER_IMG_NUM 3

class CoordSystemSample : public GLSampleBase
{
public:
    CoordSystemSample();

    virtual ~CoordSystemSample();

    virtual void LoadImage(NativeImage *pImage);
    virtual void LoadMultiImageWithIndex(int index, NativeImage *pImage);

    virtual void Init();
    virtual void Draw(int screenW, int screenH);
    virtual void delay(int seconds);

    virtual void Destroy();

    virtual void UpdateTransformMatrix(float rotateX, float rotateY, float scaleX, float scaleY);

    void UpdateMVPMatrix(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio);
    void UpdateMVPMatrix1(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio);
    void UpdateMatrix(glm::mat4 &mvpMatrix, int angleXRotate, int angleYRotate, float scale, glm::vec3 transVec3, float ratio);
    void DrawArray();
    glm::mat4 transform(float height, float dip,float fov_x,float fov_y);
    glm::mat4 buildRotateX(float rad);
    glm::mat4 buildRotateY(float rad);
    glm::mat4 buildRotateZ(float rad);

private:
    GLuint m_TextureId;
    GLint m_SamplerLoc;
    GLint m_SamplerLoc1;
    GLint m_MVPMatLoc;
    GLint m_MVPMatLoc1;
    GLint m_Offset;
    GLint m_MVPMatLoc2;
    GLuint m_VaoId;
    GLuint m_VboId;
    GLuint m_TextureIds[RENDER_IMG_NUM];
    NativeImage m_RenderImages[RENDER_IMG_NUM];
    glm::mat4 m_ModelMatrix;
    std::vector<glm::vec3> windowsTrans;
    std::map<GLfloat, glm::vec3> sorted;
    std::map<int, std::vector<int>>  Map;
    std::vector<int> Vector;
    NativeImage m_RenderImage;
    glm::mat4 m_MVPMatrix;

    int m_AngleX;
    int m_AngleY;
    float m_ScaleX;
    float m_ScaleY;
    int m_FrameIndex;
    float m_Color;
    float m_offset;
    float m_time;
    int m_i;
    CoordSystemSample* m_pCoordSystemSample;

};


#endif //NDK_OPENGLES_3_0_COORDSYSTEMSAMPLE_H

    

CoordSystemSample.cpp代码:

/**
 *
 * Created by 公众号:字节流动 on 2020/4/18.
 * https://github.com/githubhaohao/NDK_OpenGLES_3_0
 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群
 *
 * */

#include "gtc/matrix_transform.hpp"
#include "CoordSystemSample.h"
#include "../util/GLUtils.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <math.h>
#include "../glm/mat4x4.hpp"

#define DRAW_POINTS
#define POINTS_NUM           256
#define POINTS_PRE_TRIANGLES 3
#define TRIANGLES_PER_POINT  3

CoordSystemSample::CoordSystemSample()
{

    m_SamplerLoc = GL_NONE;
    m_MVPMatLoc = GL_NONE;

    m_TextureId = GL_NONE;
    m_VaoId = GL_NONE;

    m_AngleX = 0;
    m_AngleY = 0;

    m_ScaleX = 1.0f;
    m_ScaleY = 1.0f;

    m_offset=0.0f;
    m_i=0;

    //m_pCoordSystemSample = new CoordSystemSample();
}

CoordSystemSample::~CoordSystemSample()
{
    NativeImageUtil::FreeNativeImage(&m_RenderImage);

}

void CoordSystemSample::Init()
{
    if (m_ProgramObj)
        return;

    if (m_pCoordSystemSample != nullptr) {
        m_pCoordSystemSample->Init();
    }
    char vShaderStr[] =
            "#version 300 es                          \n"  //着色器版本
            "layout(location = 0) in vec3 vPosition;  \n"  //声明输入属性数组 名为vPosition的四分量
            "layout(location = 1) in vec3 aColor;  \n"
            "out vec4 vertexColor;  \n"
            "uniform mat4 u_MVPMatrix;\n"
            "void main()                              \n"  //声明main,表示着色器执行开始
            "{                                        \n"
            "   gl_Position = u_MVPMatrix * vec4(vPosition,1.0);\n" //将输入属性(vPosition*u_MVPMatrix)赋值给gl_Position的特殊输出变量
            "   vertexColor = vec4( aColor, 1.0);              \n"
            "}                                        \n"; //每个顶点着色器必须在gl_Position变量中输出一个位置;这个变量定义传递到管线下一个阶段的位置

    char vShaderStr1[] =
            "#version 300 es\n"
            "layout(location = 2) in float a_tData;\n"
            "uniform vec4 u_StartEndPoints;\n"
            "uniform vec4 u_ControlPoints;\n"
            "uniform mat4 u_MVPMatrix;\n"
           // "uniform float u_Offset;\n"
            "\n"
            "vec2 bezier3(in vec2 p0, in vec2 p1, in vec2 p2, in vec2 p3, in float t){\n"
            "    float tt = (1.0 - t) * (1.0 -t);\n"
            "    return tt * (1.0 -t) *p0 + 3.0 * t * tt * p1 + 3.0 * t *t *(1.0 -t) *p2 + t *t *t *p3;\n"
            "}\n"
            "\n"
            "vec2 bezier3_(in vec2 p0, in vec2 p1, in vec2 p2, in vec2 p3, in float t)\n"
            "{\n"
            "    vec2 q0 = mix(p0, p1, t);\n"
            "    vec2 q1 = mix(p1, p2, t);\n"
            "    vec2 q2 = mix(p2, p3, t);\n"
            "\n"
            "    vec2 r0 = mix(q0, q1, t);\n"
            "    vec2 r1 = mix(q1, q2, t);\n"
            "\n"
            "    return mix(r0, r1, t);\n"
            "}\n"
            "\n"
            "void main() {\n"
            "\n"
            "    vec4 pos;\n"
            "    pos.w = 1.0;\n"
            "\n"
            "    vec2 p0 = u_StartEndPoints.xy;\n"
            "    vec2 p3 = u_StartEndPoints.zw;\n"
            "\n"
            "    vec2 p1 = u_ControlPoints.xy;\n"
            "    vec2 p2 = u_ControlPoints.zw;\n"
            "\n"
           // "    p0.y *= u_Offset;\n"
           // "    p1.y *= u_Offset;\n"
           // "    p2.y *= u_Offset;\n"
           // "    p3.y *= u_Offset;\n"
            "\n"
            "    float t = a_tData;\n"
            "\n"
            "    vec2 point = bezier3_(p0, p1, p2, p3, t);\n"
            "\n"
            "    if (t < 0.0)\n"
            "    {\n"
            "        pos.xz = vec2(0.0, 0.0);\n"
            "    }\n"
            "    else\n"
            "    {\n"
            "        pos.xz = point;\n"
            "    }\n"
            "    gl_PointSize = 10.0;\n"
            "    gl_Position = u_MVPMatrix * pos;\n"
            "}";
    char fShaderStr[] =
            "#version 300 es                              \n"  //着色版本
            "precision mediump float;                     \n"  //声明着色器中浮点数的默认精度
            "in vec4 vertexColor;                          \n"
            "out vec4 fragColor;                          \n"  //一个4分量的输出变量 写入这个变量的值将被输出到颜色缓存区
            "void main()                                  \n"
            "{                                            \n"
            "   fragColor = vertexColor;  \n"  //所有片段的着色器输出颜色为红色
            "}                                            \n";

    char fShaderStr1[] =
            "#version 300 es\n"
            "precision mediump float;\n"
            "layout(location = 0) out vec4 outColor;\n"
            "uniform vec4 u_Color;\n"
            "void main()\n"
            "{\n"
            "    //outColor = texture(s_TextureMap, v_texCoord);\n"
            "    outColor = u_Color;\n"
            "}";

    m_ProgramObj = GLUtils::CreateProgram(vShaderStr, fShaderStr, m_VertexShader, m_FragmentShader);
    m_ProgramObj1 = GLUtils::CreateProgram(vShaderStr1, fShaderStr1, m_VertexShader1, m_FragmentShader1);
    if (!m_ProgramObj) {
        LOGCATE("BezierCurveSample::Init create program fail");
    }
};

void CoordSystemSample::LoadImage(NativeImage *pImage)
{
#if 0
    LOGCATE("CoordSystemSample::LoadImage pImage = %p", pImage->ppPlane[0]);
	if (pImage)
	{
		m_RenderImage.width = pImage->width;
		m_RenderImage.height = pImage->height;
		m_RenderImage.format = pImage->format;
		NativeImageUtil::CopyNativeImage(pImage, &m_RenderImage);
	}
#endif
}
void CoordSystemSample::LoadMultiImageWithIndex(int index, NativeImage *pImage)
{
    GLSampleBase::LoadMultiImageWithIndex(index, pImage);
    LOGCATE("BlendingSample::LoadImage index=%d, pImage = %p", index, pImage->ppPlane[0]);
    if (pImage)
    {
        m_RenderImages[index].width = pImage->width;
        m_RenderImages[index].height = pImage->height;
        m_RenderImages[index].format = pImage->format;
        NativeImageUtil::CopyNativeImage(pImage, &m_RenderImages[index]);
    }
}
void CoordSystemSample::DrawArray() {
#ifdef DRAW_POINTS
    glDrawArrays(GL_POINTS, 0, POINTS_NUM * TRIANGLES_PER_POINT);
#else
    glDrawArrays(GL_TRIANGLES, 0, POINTS_NUM * POINTS_PRE_TRIANGLES);
    glDrawArrays(GL_LINES, 0, POINTS_NUM * POINTS_PRE_TRIANGLES);
#endif
}
glm::mat4 CoordSystemSample::transform(float height, float dip,float fov_x,float fov_y)
{
    float distance= height/(tan(glm::radians(dip)));
    float radiansY=0.0;
    float radiansZ=0.0;
    LOGCATD("distance = %f",distance);
    //glm::mat4 Projection = glm::frustum(-0.699f, 0.699f, -0.3934f, 0.3934f, imagez, 100.0f);
    // glm::mat4 Projection = glm::perspective(glm::radians(fov_y), fov_x/fov_y,2.0f,200.0f); //描绘的是屏幕  任务:加一个横向fov 算出来高宽比
    glm::mat4 Projection = glm::perspective(glm::radians(4.0f), fov_x/fov_y,0.1f, 200.f);
    LOGCATD("aspect = %f",fov_x/fov_y);
    //透视投影矩阵 第1个参数为视锥上下面之间的夹角 第2个参数为宽高比  第3,第4分别为近界面和远界面的深度
    //glm::mat4 Projection = glm::pers pective(10.0f,854.0f/480.0f, imagez,100.0f);

    //摄像机位置:世界空间中一个指向摄像机位置的向量(即摄像机位置)
    glm::vec3 cameraPos = glm::vec3(-0.37, height, 1.31834);
    //摄像机方向:摄像机指向哪个方向(即中心坐标)
    glm::vec3 cameraTarget = glm::vec3(-0.37f+distance*sin(glm::radians(0.0)), 0.0f, -distance*cos(glm::radians(0.0))+1.31834);
    glm::vec3 cameraDirection = glm::normalize(cameraPos - cameraTarget);
    LOGCATD("cameraDirection[0]:%f,cameraDirection[1]:%f,cameraDirection[2]:%f,",cameraDirection[0],cameraDirection[1],cameraDirection[2]);
    //glm::vec3 right = glm::vec3(1.0f, 0.0f, 0.0f); //右向量
    //glm::vec3 right = glm::vec3(cos(glm::radians(0.0)), sin(glm::radians(0.0)), 0.0f); //右向量 上下
    glm::vec3 right = glm::vec3(cos(glm::radians(0.0)), 0.0, sin(glm::radians(0.0))); //右向量 水平倾角
    //glm::vec4 right_trans=glm::vec4(1.0f, 0.0f, 0.0f,1.0);
    glm::vec3 cameraUp = glm::normalize(glm::cross(cameraDirection,right ));
    LOGCATD("cameraUp[0]:%f,cameraUp[1]:%f,cameraUp[2]:%f,",cameraUp[0],cameraUp[1],cameraUp[2]);
    //glm::vec3 cameraUp = glm::normalize(glm::cross(cameraDirection, cameraRight));
    glm::mat4 View = glm::lookAt(
            //glm::vec3(-0.087f, 0.380198f, 0.311671f), // Camera is at (0,0,1), in World Space  0.35628f
            cameraPos,
            //glm::vec3(0, 0, -distance), // and looks at the origin
            cameraTarget,
            cameraUp
            //glm::vec3(-tan(glm::radians(0.0f)), 1.0f, 0)  // Head is up (set to 0,-1,0 to look upside-down)
    ); //描绘的是人眼
    //将顶点的世界空间坐标装换为观察空间坐标
    //glm::lookAt函数有三个参数,eye表示摄像机所在的位置,center表示摄像机要看向的中心点的位置,up表示摄像机的三个方位向量中的up向量
    glm::mat4 Model = glm::mat4(1.0f);
    //LOGCATD("XXCC Model = %f",Model[0][0]);
    Model = glm::scale(Model, glm::vec3(1.0, 1.0, 1.0f)); //用于对物体进行缩放
    //Model = glm::rotate(Model, 1, glm::vec3(1.0f, 0.0f, 0.0f));
    //Model = glm::rotate(Model, 1, glm::vec3(0.0f, 1.0f, 0.0f));
    //Model = glm::rotate(Model, glm::radians(5.0f), glm::vec3(0.0f, 0.0f, 1.0f));
    Model = glm::translate(Model, glm::vec3(0.0f, 0.0f, 0.0f)); //用于对物体进行位移

    m_MVPMatrix = Projection * View;
    /*LOGCATE("XXCCCC2: {%f, %f, %f, %f;  %f, %f, %f, %f;  %f, %f, %f, %f;  %f, %f, %f, %f}",
            m_MVPMatrix[0][0],m_MVPMatrix[0][1],m_MVPMatrix[0][2],m_MVPMatrix[0][3],
            m_MVPMatrix[1][0],m_MVPMatrix[1][1],m_MVPMatrix[1][2],m_MVPMatrix[1][3],
            m_MVPMatrix[2][0],m_MVPMatrix[2][1],m_MVPMatrix[2][2],m_MVPMatrix[2][3],
            m_MVPMatrix[3][0],m_MVPMatrix[3][1],m_MVPMatrix[3][2],m_MVPMatrix[3][3]);*/
    return m_MVPMatrix = Projection * View * Model;       //* buildRotateY(glm::radians(0.0)) * buildRotateZ(glm::radians(2.0));
}
void CoordSystemSample::delay(int seconds)
{
    clock_t start = clock();
    clock_t lay = (clock_t)seconds * CLOCKS_PER_SEC;
    while ((clock()-start) < lay);
}

void CoordSystemSample::Draw(int screenW, int screenH)
{
    float degree = 0.0f;
    //float degree = 5.2f;
    //LOGCATE("TriangleSample::Draw");
    float imagey_clib = 0.5f;

    float imagez = 7.8f;
    float fovx_clib = 10.0f;
    float fovx = 10.0f;
    //fovx_clib / 440.f * 480.f;
    float aspect = 854.0f/480.0f;
    float halfimagewidth = imagez * tan(glm::radians(fovx/2))-0.16;
    float halfimageheight = halfimagewidth / aspect;
    //float imagey = imagey_clib - 55.0f/480.f * halfimageheight;
    // float imagey = 1.3296f - 0.35628f;
    float imagey =0.0f;
    GLfloat vVertices[] = {  //顶点数据
            1.2f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,0,0,//红色代表:最右端
            1.2f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,0,0,
            0.4f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,1,1, //白色代表:
            0.4f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,1,1,
            -0.37f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),0,1,0, //绿色代表:
            -0.37f, -imagey, -120.0f / abs(cos(glm::radians(degree))),0,1,0,
            -1.0f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,1,1, //白色代表:
            -1.0f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,1,1,
            -2.0f,  -imagey, -0.1f / abs(cos(glm::radians(degree))),1,0,0, //红色代表:最左端
            -2.0f, -imagey, -120.0f / abs(cos(glm::radians(degree))),1,0,0,
            2.0f, -imagey, -85.0f / abs(cos(glm::radians(degree))),1,1,0, //黄色代表(最上端):
            -2.0f, -imagey, -85.0f / abs(cos(glm::radians(degree))),1,1,0,
            2.0f, -imagey, -30.0f / abs(cos(glm::radians(degree))),0,1,1, //青色代表(中):
            -2.0f, -imagey, -30.0f / abs(cos(glm::radians(degree))),0,1,1,

            //2.0f, -imagey, -16.70771550640865f / abs(cos(glm::radians(degree))),0,1,0,
            //-2.0f, -imagey, -16.70771550640865f / abs(cos(glm::radians(degree))),0,1,0,
            2.0f, -imagey, -13.5f / abs(cos(glm::radians(degree))),0,1,0,
            -2.0f, -imagey, -13.5f / abs(cos(glm::radians(degree))),0,1,0,

    };

    if(m_ProgramObj == 0)
        return;

    float dip=2.5f; //倾角
    float height = 1.326f; //摄像机高度
    float fov_x=10.0; //横向fov
    float fov_y=4.0; //纵向fov
    glm::mat4 m_MVPMatrix=transform(height, dip,fov_x,fov_y);
    glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清除模板缓冲 颜色缓冲 深度缓冲
    glClearColor(0.0, 0.0, 0.0, 1.0);   //用于设置背景色
    //glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    // Use the program object
    glUseProgram (m_ProgramObj); //激活着色器
    glUniformMatrix4fv(m_MVPMatLoc, 1, GL_FALSE, &m_MVPMatrix[0][0]); //通过一致变量引用将一致变量值传入渲染管线
    LOGCATE("m_MVPMatrix1=%f",m_MVPMatrix[0][0]);
    // Load the vertex data
    glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); //更新顶点格式
    glEnableVertexAttribArray (0); //启用指定属性 可在顶点着色器中访问逐顶点的属性数据(即允许着色器读取GPU数据)

    unsigned int VBO, VAO;
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
    glBindVertexArray(VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vVertices), vVertices, GL_STREAM_DRAW);
    // 位置属性
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);
    // 颜色属性
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3* sizeof(float)));
    glEnableVertexAttribArray(1);
    //GL_LINE_STRIP GL_LINES
    glLineWidth(10);  //线条的栅格化宽度
    //glEnable(GL_LINE_SMOOTH);
    //glDrawArrays (GL_LINES, 0, 36); //画直线
    LOGCATE("BezierCurveSample::Draw()");

    int tDataSize = POINTS_NUM * POINTS_PRE_TRIANGLES;
    float *p_tData = new float[tDataSize];

    for (int i = 0; i < tDataSize; i += POINTS_PRE_TRIANGLES) {
#ifdef DRAW_POINTS
        float t0 = (float) i / tDataSize;
        float t1 = (float) (i + 1) / tDataSize;
        float t2 = (float) (i + 2) / tDataSize;

        p_tData[i] = t0;
        p_tData[i + 1] = t1;
        p_tData[i + 2] = t2;
#else
        float t = (float) i / tDataSize;
        float t1 = (float) (i + 3) / tDataSize;

        p_tData[i] = t;
        p_tData[i + 1] = t1;
        p_tData[i + 2] = -1;
#endif

    }
    glUseProgram(m_ProgramObj1);
    glUniformMatrix4fv(m_MVPMatLoc, 1, GL_FALSE, &m_MVPMatrix[0][0]);
    GLUtils::setVec4(m_ProgramObj1, "u_Color", glm::vec4(0.0f, 1.0f, 1.0f, 1.0f));
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
    glBindVertexArray(VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(float) * tDataSize, p_tData, GL_STREAM_DRAW);
    // Generate VBO Ids and load the VBOs with data

    delete[] p_tData;

    glEnableVertexAttribArray(2);
    glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), (const void *) 0);


    if (m_ProgramObj1 == GL_NONE) return;

    m_FrameIndex++;

    //UpdateMVPMatrix(m_MVPMatrix, m_AngleX, m_AngleY, (float) screenW / screenH);
    // Use the program object
    //draw one
    GLUtils::setMat4(m_ProgramObj1, "u_MVPMatrix", m_MVPMatrix);
    LOGCATE("m_MVPMatrix2=%f",m_MVPMatrix[0][0]);

    //(-2.168064710585829, -4.786828947528996)  (2.593669136574661E-6, -85.86069395120855
    /*GLUtils::setVec4(m_ProgramObj1, "u_StartEndPoints", glm::vec4(-1, 0,
                                                                 1, 0));
    GLUtils::setVec4(m_ProgramObj1, "u_ControlPoints", glm::vec4(-0.04f, 0.99f,
                                                                0.0f, 0.99f));*/
     GLUtils::setVec4(m_ProgramObj1, "u_StartEndPoints", glm::vec4(-2.168064710585829, -4.786828947528996,
                                                                   2.593669136574661E-6, -85.86069395120855));
     GLUtils::setVec4(m_ProgramObj1, "u_ControlPoints", glm::vec4(-1.685050938811831, -21.950682715419084,
                                                                  1.3268512389760134, -34.58404534596737));
    glEnable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
    glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Screen blend mode
    glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
    DrawArray();
    GLUtils::setVec4(m_ProgramObj1, "u_StartEndPoints", glm::vec4(2.168064710585829, -4.786828947528996,
                                                                  -2.593669136574661E-6, -85.86069395120855));
    GLUtils::setVec4(m_ProgramObj1, "u_ControlPoints", glm::vec4(-1.685050938811831, -21.950682715419084,
                                                                 1.3268512389760134, -34.58404534596737));
    DrawArray();
    /*float offset = (m_FrameIndex % 100) * 1.0f / 100;
           offset = (m_FrameIndex / 100) % 2 == 1 ? (1 - offset) : offset;
           GLUtils::setFloat(m_ProgramObj, "u_Offset", offset);*/
    /*GLUtils::setVec4(m_ProgramObj, "u_StartEndPoints", glm::vec4(-1, 0,
                                                         1, 0));
GLUtils::setVec4(m_ProgramObj, "u_ControlPoints", glm::vec4(-0.04f, 0.99f,
                                                        0.0f, 0.99f));*/
   /* GLfloat p_tData[10][200]={{-2.168064710585829, -4.786828947528996, -2.1595033603895164, -5.003244522349575, -2.1480500073589957, -5.222606301774769, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.1151137914646543, -6.743350373943072, -2.089940584405955, -7.146851586541547, -2.0906566999787635, -7.600914934304177, -2.071231737458623, -8.159734113598189, -2.0454397762986036, -8.756416627618139, -2.0339469749881873, -9.44783549412571, -2.013837504834276, -10.324547817010957, -1.9754179299954777, -11.298606801812854, -1.9527304195994724, -12.473452033339026, -1.915446880798522, -14.048038135668069, -1.8327722308945662, -15.90947153403217, -1.7956345806666794, -18.34175760037252, -1.685050938811831, -21.950682715419084, -1.520377510848388, -26.86080355929723, -1.326849060242521, -34.584044120003384, -0.9126497220349112, -50.09183138183028, 2.593669136574661E-6, -85.86069395120855, 2.14038741066906, -4.786828948834825, 2.1305819759884645, -5.003244486039925, 2.1329588070271157, -5.222606225513782, 2.1143945139015643, -5.461670462730262, 2.124051095659115, -5.745150828795599, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 2.00670735645765, -9.447835013675586, 2.0039177193129576, -10.324548611608883, 1.9645643861488278, -11.298606686546204, 1.9167911573591778, -12.473452315033478, 1.9019588347176697, -14.04803888583478, 1.8327731846147466, -15.909473239919436, 1.7780314959972423, -18.341756142341005, 1.6850522033031978, -21.95068214685878, 1.5719172072866336, -26.860803676950383, 1.3268512389760134, -34.58404534596737, 0.8646185338698238, -50.091830941049814, 2.593669136574661E-6, -85.86069395120855},
                               {-2.2049678156514023, -4.786829078782961, -2.198066025176287, -5.00324466686155, -2.188294625614369, -5.222605905348471, -2.182770015897539, -5.461670620679042, -2.173832948520706, -5.745150796939978, -2.161193649917144, -6.035502145549806, -2.147354208956651, -6.357028025276187, -2.147554022042002, -6.743351054723037, -2.131189353407843, -7.146851885468177, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0435988641635556, -10.324548045529285, -2.0079797182261108, -11.298607045825198, -1.9886703637482839, -12.473451102906733, -1.955914185958793, -14.048038435968497, -1.8785914806843345, -15.909471868146126, -1.8484475395596232, -18.341756227181293, -1.748240543078457, -21.950683189215088, -1.5976847588788912, -26.860804140071018, -1.4263629378619451, -34.58404151521079, -0.24694554594121976, -85.86069581467021, 2.1034840821165393, -4.786829083779365, 2.092019549587771, -5.003244626615285, 2.0876835599237573, -5.222606041191612, 2.07231703556208, -5.46167061647896, 2.0742684469654376, -5.745151217733758, 2.0566199487800603, -6.035502069428346, 2.0494695919295793, -6.357027530797484, 2.037257156748324, -6.743350987825565, 2.0280679205219165, -7.146852045500597, 2.017557058403818, -7.600914754724766, 2.000622039004057, -8.159733531554625, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8688714088399083, -12.473451866370922, 1.8210243656520189, -14.048038113009271, 1.7869537942541998, -15.909470476490615, 1.6724059206176967, -18.341755178687325, 1.6218627331287405, -21.950682618440435, 1.443071729804439, -26.86080377164454, 1.2273374209531085, -34.584042740190625, -0.24694554594121976, -85.86069581467021},
                               {-2.200354825814602, -4.7868293550347785, -2.198066025176287, -5.00324466686155, -2.1832642262950763, -5.222606233549631, -2.1775104948623114, -5.461670950663911, -2.173832948520706, -5.745150796939978, -2.1553838973750796, -6.035501913850994, -2.1412364524450984, -6.357027774404684, -2.134577999795926, -6.743350515309284, -2.1243144291067497, -7.146852305443537, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0535191382013136, -10.324548436679715, -2.018833709766037, -11.298606373093529, -1.9766903758043213, -12.47345181036096, -1.9828922328896987, -14.048038186488464, -1.9244109236707134, -15.90947223525684, -1.8660518496043061, -18.341756951612545, -1.8324929848455822, -21.950682394162374, -1.7265304002515136, -26.860804237471598, -1.5590478620451187, -34.584043611886166, -0.7802191759798485, -81.38057409088681, 2.1034840821165393, -4.786829083779365, 2.0968397009440976, -5.003244432714191, 2.092714069578704, -5.22260583105579, 2.0828361814343674, -5.461671244928169, 2.0797997776919006, -5.745150963795188, 2.074049051865287, -6.035501943205265, 2.0617052637855213, -6.357027622559288, 2.0567215289700247, -6.743350843752931, 2.0418175785246984, -7.146852173245545, 2.0248669647953075, -7.6009144297536695, 2.008467549264596, -8.159733989291261, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.725861405495664, -15.90947145941073, 1.6548016400976284, -18.341757691014156, 1.516547116812408, -21.95068270616467, 1.2884569376475334, -26.86080234492618, 0.995138679239107, -34.58404226088751, -0.7802191759798485, -81.38057409088681},
                               {-2.200354825814602, -4.7868293550347785, -2.198066025176287, -5.00324466686155, -2.188294625614369, -5.222605905348471, -2.1775104948623114, -5.461670950663911, -2.173832948520706, -5.745150796939978, -2.1553838973750796, -6.035501913850994, -2.1412364524450984, -6.357027774404684, -2.134577999795926, -6.743350515309284, -2.1243144291067497, -7.146852305443537, -2.112586626127997, -7.600915107862952, -2.102613932194414, -8.15973380531535, -2.079109670522874, -8.756416332827918, -2.0611875340612316, -9.447835704839378, -2.0535191382013136, -10.324548436679715, -2.018833709766037, -11.298606373093529, -1.9766903758043213, -12.47345181036096, -1.9828922328896987, -14.048038186488464, -1.9244109236707134, -15.90947223525684, -1.8660518496043061, -18.341756951612545, -1.8114300132529146, -21.95068366079674, -1.7265304002515136, -26.860804237471598, -1.5258764812771153, -34.58404561133605, -0.7021969799202927, -81.38057875299079, 2.1034840821165393, -4.786829083779365, 2.0968397009440976, -5.003244432714191, 2.092714069578704, -5.22260583105579, 2.0828361814343674, -5.461671244928169, 2.0797997776919006, -5.745150963795188, 2.074049051865287, -6.035501943205265, 2.0617052637855213, -6.357027622559288, 2.0567215289700247, -6.743350843752931, 2.0349426542236055, -7.146851753270186, 2.0248669647953075, -7.6009144297536695, 2.008467549264596, -8.159733989291261, 1.9865183061330645, -8.756416295521703, 1.9613068367600839, -9.447835050060604, 1.944395371301159, -10.324548049107708, 1.8994406578806236, -11.298606104047892, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.725861405495664, -15.90947145941073, 1.6548016400976284, -18.341757691014156, 1.516547116812408, -21.95068270616467, 1.3142259995291141, -26.860803900319613, 0.995138679239107, -34.58404226088751, -0.7021969799202927, -81.38057875299079},
                               {-2.1772904291009914, -4.78682886761486, -2.1691441477475553, -5.003244441252837, -2.1530806450643656, -5.222605977510224, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.0237580321572413, -10.324548212344043, -1.9971257602842378, -11.298606586469038, -1.9766903758043213, -12.47345181036096, -1.955914185958793, -14.048038435968497, -1.909137784701946, -15.909471586450682, -1.883655965686657, -18.341755884457637, -1.8324929848455822, -21.950682394162374, -1.7265304002515136, -26.860804237471598, -1.6253903588965395, -34.58404300654346, -1.4410266914979077, -50.09183374703773, -0.9877894613991656, -85.8606930807611, 2.1311614760481037, -4.786829319585159, 2.1257615783728294, -5.003244207105479, 2.1228976513014914, -5.222605604814643, 2.1143945139015643, -5.461670462730262, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 1.9976271006891144, -9.447835393059018, 1.984076870083951, -10.324547401855037, 1.942856437159106, -11.298606502968957, 1.8808513771007946, -12.473451381894762, 1.8480024130750015, -14.04803839228756, 1.7564076201184968, -15.909471742582403, 1.6724059206176967, -18.341755178687325, 1.5376103416902833, -21.95068396861638, 1.365764438963244, -26.86080175996974, 0.995138679239107, -34.58404226088751, 0.38427571448675657, -50.09183132922181, -0.9877894613991656, -85.8606930807611},
                               {-2.1772904291009914, -4.78682886761486, -2.1691441477475553, -5.003244441252837, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.033678320602052, -10.32454863353877, -1.9971257602842378, -11.298606586469038, -1.9886703637482839, -12.473451102906733, -1.969403280297729, -14.048038983042536, -1.9244109236707134, -15.90947223525684, -1.9012604843191583, -18.341756612333423, -1.8746190955579194, -21.95068415577966, -1.8038378549831373, -26.86080222850322, -1.7249039574243241, -34.58404376526364, -1.5370952203655257, -50.09183287625094, -1.234737332825185, -85.86069493979406, 2.1265484867033804, -4.7868290731316, 2.1257615783728294, -5.003244207105479, 2.1228976513014914, -5.222605604814643, 2.1091347489305905, -5.46167070309498, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.984076870083951, -10.324547401855037, 1.9320024638260258, -11.298606932772895, 1.8688714088399083, -12.473451866370922, 1.8345134826264935, -14.048038936655178, 1.741134480657652, -15.909472361590304, 1.6371974197213688, -18.341756625581517, 1.4954839268719944, -21.950683559389393, 1.2884569376475334, -26.86080234492618, 0.9287961073999602, -34.584041626976735, 0.2882071404296722, -50.09183042937489, -1.234737332825185, -85.86069493979406},
                               {-2.181903172678483, -4.786829064198581, -2.1691441477475553, -5.003244441252837, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.089940584405955, -7.146851586541547, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.043027245519031, -9.447834979561351, -2.033678320602052, -10.32454863353877, -2.0079797182261108, -11.298607045825198, -2.0006503320091698, -12.473451587382893, -1.9828922328896987, -14.048038186488464, -1.9549570191005075, -15.909471950116858, -1.936468686467168, -18.341756295717452, -1.8956823204357942, -21.950682893327944, -1.8553760844348286, -26.860801742423593, -1.791246871943457, -34.58404313701175, -1.6811983673910635, -50.091829101982015, -1.481685472435541, -85.86069680325572, 2.1265484867033804, -4.7868290731316, 2.1209413078234642, -5.00324440297488, 2.1228976513014914, -5.222605604814643, 2.1091347489305905, -5.46167070309498, 2.118519481357107, -5.745151057610639, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.9741564940758467, -10.324548837912864, 1.9211486399763213, -11.298607389914709, 1.8568914410710995, -12.473452380645345, 1.8210243656520189, -14.048038113009271, 1.7105882558380265, -15.909470558461345, 1.6195930801520704, -18.341755562117186, 1.4744208365783646, -21.950682324521598, 1.23691884089339, -26.860804479617173, 0.8292823747800069, -34.58404238791125, 0.1441043715952689, -50.091831507301514, -1.481685472435541, -85.86069680325572},
                               {-2.181903172678483, -4.786829064198581, -2.1739645374899594, -5.003244639090546, -2.158111288811481, -5.222606189860391, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.033678320602052, -10.32454863353877, -2.0079797182261108, -11.298607045825198, -2.0006503320091698, -12.473451587382893, -1.9963813272286348, -14.048038733562503, -1.9702301841493521, -15.909471019615255, -1.9540732050996692, -18.341757023593242, -1.937808735254083, -21.95068248410096, -1.906914270583751, -26.860803878590815, -1.8575891602070602, -34.5840425282245, -1.8253007431352026, -50.09183503185817, -1.728633496542227, -85.86069031902201, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9885469339601032, -9.447834846974128, 1.9741564940758467, -10.324548837912864, 1.9211486399763213, -11.298607389914709, 1.8449114526350596, -12.473451643392858, 1.794046333620243, -14.048037863283199, 1.6953152313599609, -15.909472725502518, 1.5843844749618334, -18.341757010733648, 1.432294481356595, -21.95068191431046, 1.1853804326521407, -26.860803996490006, 0.7629399032429413, -34.58404512046571, 1.5436564230197902E-6, -50.091832616010564, -1.728633496542227, -85.86069031902201},
                               {-2.181903172678483, -4.786829064198581, -2.1739645374899594, -5.003244639090546, -2.1631419260247746, -5.222605895394106, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.0435988641635556, -10.324548045529285, -2.0079797182261108, -11.298607045825198, -2.0126301507866806, -12.473452099196928, -2.0098702649214744, -14.048037936762393, -1.9855035168068071, -15.909471671619913, -1.9892816163275735, -18.341756680623543, -1.9799348813959579, -21.950682100243544, -1.958452514934572, -26.86080339275722, -1.9239318656462987, -34.58404192632633, -1.9694040540511688, -50.09183126029566, -1.9755813828673763, -85.86069217830101, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9794668126389905, -9.447836148135304, 1.9741564940758467, -10.324548837912864, 1.9102946489284724, -11.298606746981301, 1.8449114526350596, -12.473451643392858, 1.7805572397733835, -14.048038440155496, 1.6800420663111166, -15.909471795000915, 1.56678017981628, -18.34175773491886, 1.3901682360600127, -21.950683648343826, 1.1338422032004494, -26.860803510410378, 0.6634261001191663, -34.58404251444293, -0.0960671495937, -50.091831718131935, -1.9755813828673763, -85.86069217830101},
                               {-2.186516386002231, -4.786828791637338, -2.1739645374899594, -5.003244639090546, -2.1631419260247746, -5.222605895394106, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.116765107749061, -6.3570280175248115, -2.108625605379457, -6.743350771990615, -2.083065660104862, -7.146852006516905, -2.0833465994065095, -7.600914635932841, -2.071231737458623, -8.159734113598189, -2.053857347259503, -8.756416972818489, -2.0521075017796435, -9.447835329146523, -2.0435988641635556, -10.324548045529285, -2.018833709766037, -11.298606373093529, -2.0126301507866806, -12.473452099196928, -2.023359359260411, -14.048038483836432, -2.000776268890276, -15.909472284230814, -2.0068859263722567, -18.341757405054796, -2.000998339520709, -21.950682957896962, -2.0099907443862635, -26.86080290667759, -1.9902742924859744, -34.58404465814267, -2.0654725829187868, -50.09183038950887, -2.2225297752708633, -85.8606940757436, 2.121935750151788, -4.786828792697128, 2.1209413078234642, -5.00324440297488, 2.1178668967266447, -5.2226063257035324, 2.1091347489305905, -5.46167070309498, 2.1129882897804038, -5.745150713123631, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.076191434543263, -7.146852139703527, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.0286055632224937, -8.75641627835437, 1.9794668126389905, -9.447836148135304, 1.964236069215305, -10.324548218136812, 1.9102946489284724, -11.298606746981301, 1.8329316136823954, -12.473450933478246, 1.7805572397733835, -14.048038440155496, 1.6647688123595703, -15.909470895773802, 1.5491759450329674, -18.34175669953052, 1.3691051807038443, -21.95068452915246, 1.082303973748758, -26.860803024330746, 0.5970836032677456, -34.584041909100215, -0.19213567895339512, -50.091830817546885, -2.2225297752708633, -85.8606940757436}};

   // GLfloat p_tData[1024]={-2.168064710585829, -4.786828947528996, -2.1595033603895164, -5.003244522349575, -2.1480500073589957, -5.222606301774769, -2.1459521684368594, -5.461670705080716, -2.1406446952670786, -5.745151116864046, -2.1263355828964503, -6.035502491529222, -2.122883023585527, -6.357027645093246, -2.1151137914646543, -6.743350373943072, -2.089940584405955, -7.146851586541547, -2.0906566999787635, -7.600914934304177, -2.071231737458623, -8.159734113598189, -2.0454397762986036, -8.756416627618139, -2.0339469749881873, -9.44783549412571, -2.013837504834276, -10.324547817010957, -1.9754179299954777, -11.298606801812854, -1.9527304195994724, -12.473452033339026, -1.915446880798522, -14.048038135668069, -1.8327722308945662, -15.90947153403217, -1.7956345806666794, -18.34175760037252, -1.685050938811831, -21.950682715419084, -1.520377510848388, -26.86080355929723, -1.326849060242521, -34.584044120003384, -0.9126497220349112, -50.09183138183028, 2.593669136574661E-6, -85.86069395120855, 2.14038741066906, -4.786828948834825, 2.1305819759884645, -5.003244486039925, 2.1329588070271157, -5.222606225513782, 2.1143945139015643, -5.461670462730262, 2.124051095659115, -5.745150828795599, 2.1030972219181323, -6.0355018973343855, 2.104530200739482, -6.357027703863293, 2.0891617703730643, -6.743350818534679, 2.0693166890317283, -7.146851716775706, 2.061417104390972, -7.600914404408715, 2.0476952414669265, -8.159733980555986, 2.037023147961547, -8.756416767505293, 2.00670735645765, -9.447835013675586, 2.0039177193129576, -10.324548611608883, 1.9645643861488278, -11.298606686546204, 1.9167911573591778, -12.473452315033478, 1.9019588347176697, -14.04803888583478, 1.8327731846147466, -15.909473239919436, 1.7780314959972423, -18.341756142341005, 1.6850522033031978, -21.95068214685878, 1.5719172072866336, -26.860803676950383, 1.3268512389760134, -34.58404534596737, 0.8646185338698238, -50.091830941049814, 2.593669136574661E-6, -85.86069395120855};

   for(int j=0,m=0;j<10;j++)
   {
       while (p_tData[j][m]!=0)
       {
           m++;
       }
       LOGCATE("m=%d",m);
      for(int i=0;i<m/2;i=i+2)
      {
          p_tData[j][m+i]=(p_tData[j][i]+p_tData[j][m/2+i])/2.0;
          p_tData[j][m+i+1]=(p_tData[j][i+1]+p_tData[j][m/2+i+1])/2.0;
      }
       LOGCATE("p_tData[0][0]=%f",p_tData[0][0]);
       LOGCATE("p_tData[0][48]=%f",p_tData[0][48]);
       LOGCATE("p_tData[0][96]=%f",p_tData[0][96]);
       LOGCATE("p_tData[0][1]=%f",p_tData[0][1]);
       LOGCATE("p_tData[0][49]=%f",p_tData[0][49]);
       LOGCATE("p_tData[0][97]=%f",p_tData[0][97]);
      m=0;
   }
    glUseProgram(m_ProgramObj1);
    glUniformMatrix4fv(m_MVPMatLoc1, 1, GL_FALSE, &m_MVPMatrix[0][0]); //通过一致变量引用将一致变量值传入渲染管线
    GLUtils::setVec4(m_ProgramObj1, "u_Color", glm::vec4(0.0f, 1.0f, 1.0f, 1.0f));
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
    glBindVertexArray(VAO);
    m_i++;
    if(m_i>9)
        m_i=0;
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(p_tData[m_i]), p_tData[m_i], GL_STREAM_DRAW);
    LOGCATE("p_tData[m_i]=%d",sizeof(p_tData[m_i]));
    // 位置属性
    glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(3);
    // 颜色属性
    glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)(1* sizeof(float)));
    glEnableVertexAttribArray(2);
    //GL_LINE_STRIP GL_LINES

    if (m_ProgramObj1 == GL_NONE) return;
    // Use the program object
    glEnable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
    glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Screen blend mode
    glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
    m_offset=0.0f;
    GLUtils::setFloat(m_ProgramObj1, "u_offset", m_offset);
    glDrawArrays (GL_POINTS, 0, 200);
    //DrawArray();
    delay(1);*/
}

void CoordSystemSample::Destroy()
{
    if (m_ProgramObj)
    {
        glDeleteProgram(m_ProgramObj);
        m_ProgramObj = GL_NONE;
    }
    if (m_ProgramObj1)
    {
        glDeleteProgram(m_ProgramObj1);
        m_ProgramObj1 = GL_NONE;
    }
}


/**
 * @param angleX 绕X轴旋转度数
 * @param angleY 绕Y轴旋转度数
 * @param ratio 宽高比
 * */
glm::mat4 CoordSystemSample::buildRotateX(float rad)
{
    glm::mat4 xrot = glm::mat4(1.0, 0.0, 0.0, 0.0,
                               0.0, cos(rad), -sin(rad), 0.0,
                               0.0, sin(rad), cos(rad), 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return xrot;
}
glm::mat4 CoordSystemSample::buildRotateY(float rad)
{
    glm::mat4 yrot = glm::mat4(cos(rad), 0.0, sin(rad), 0.0,
                               0.0, 1.0, 0.0, 0.0,
                               -sin(rad), 0.0, cos(rad), 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return yrot;
}
glm::mat4 CoordSystemSample::buildRotateZ(float rad)
{
    glm::mat4 zrot = glm::mat4(cos(rad), -sin(rad), 0.0, 0.0,
                               sin(rad), cos(rad), 0.0, 0.0,
                               0.0, 0.0, 1.0, 0.0,
                               0.0, 0.0, 0.0, 1.0);
    return zrot;
}
float distance_z = -0.2f;
void CoordSystemSample::UpdateMVPMatrix(glm::mat4 &mvpMatrix, int angleX, int angleY, float ratio)
{
    angleX = angleX % 360;
    angleY = angleY % 360;

    //转化为弧度角
    float radiansX = static_cast<float>(MATH_PI / 180.0f * angleX);
    float radiansY = static_cast<float>(MATH_PI / 180.0f * angleY);


    // Projection matrix
    glm::mat4 Projection = glm::ortho(-1.0f, 1.0f, -1.0f, 1.0f, 0.1f, 100.0f);
    //glm::mat4 Projection = glm::frustum(-ratio, ratio, -1.0f, 1.0f, 4.0f, 100.0f);
    //glm::mat4 Projection = glm::perspective(45.0f, ratio, 0.1f, 100.f);

    // View matrix
    glm::mat4 View = glm::lookAt(
            glm::vec3(0, 0, 4), // Camera is at (0,0,1), in World Space
            glm::vec3(0, 0, 0), // and looks at the origin
            glm::vec3(0, 1, 0)  // Head is up (set to 0,-1,0 to look upside-down)
    );

    // Model matrix
    glm::mat4 Model = glm::mat4(1.0f);
    Model = glm::scale(Model, glm::vec3(m_ScaleX, m_ScaleY, 1.0f));
    Model = glm::rotate(Model, radiansX, glm::vec3(1.0f, 0.0f, 0.0f));
    Model = glm::rotate(Model, radiansY, glm::vec3(0.0f, 1.0f, 0.0f));
    Model = glm::translate(Model, glm::vec3(0.0f, 0.0f, 0.0f));

    mvpMatrix = Projection * View * Model;
}

void CoordSystemSample::UpdateTransformMatrix(float rotateX, float rotateY, float scaleX, float scaleY)
{

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值