2018-11-30 19:26:08 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VERTEX_ARRAY_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VERTEX_ARRAY_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/type/List.h>
|
2019-03-27 14:12:47 +08:00
|
|
|
|
#include<hgl/graph/BufferObject.h>
|
2018-11-30 19:26:08 +08:00
|
|
|
|
#include<hgl/graph/PixelCompoment.h>
|
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 顶点阵列数据
|
|
|
|
|
*/
|
|
|
|
|
class VertexArray
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
2018-12-06 21:17:45 +08:00
|
|
|
|
GLuint vao;
|
2018-12-05 21:58:03 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
ObjectList<VertexBufferObject> vbo_list; ///<顶点数据缓冲区
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
ElementBufferObject *element_buffer;
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
VertexBufferObject *position_buffer;
|
|
|
|
|
int position_compoment; ///<位置属性格式
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
VertexArray(uint max_vertex_attrib);
|
2018-12-05 21:58:03 +08:00
|
|
|
|
~VertexArray();
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
static int GetMaxVertexAttrib();
|
2018-12-06 21:17:45 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
const GLuint GetVAO ()const{return vao;} ///<取得VAO对象
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
|
|
|
|
public: //通用顶点缓冲区设置
|
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
int AddBuffer (int shader_location,VertexBufferObject *); ///<设置顶点缓冲区对象
|
|
|
|
|
VertexBufferObject *GetBuffer (int index){return vbo_list[index];} ///<取得顶点缓冲区对象
|
|
|
|
|
bool ClearBuffer (int index){return vbo_list.Delete(index);} ///<清除顶点缓冲区对象
|
|
|
|
|
void ClearBuffers(){ vbo_list.Clear();} ///<清除所有顶点缓冲区对象
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2018-11-30 19:36:07 +08:00
|
|
|
|
public: //特殊缓冲区独立设置函数
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
bool SetElement (ElementBufferObject *eb); ///<设置索引缓冲区对象
|
|
|
|
|
bool SetPosition (int shader_location,VertexBufferObject *vb); ///<设置位置缓冲区对象
|
2018-11-30 19:26:08 +08:00
|
|
|
|
|
2019-03-27 14:12:47 +08:00
|
|
|
|
ElementBufferObject * GetElement (){return element_buffer;} ///<获取索引缓冲区对象
|
|
|
|
|
VertexBufferObject * GetPosition (){return position_buffer;} ///<获取位置缓冲区对象
|
2018-11-30 19:26:08 +08:00
|
|
|
|
};//class VertexArray
|
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_VERTEX_ARRAY_INCLUDE
|