vao构造无需再传入属性个数

This commit is contained in:
HuYingzhuo 2019-03-27 16:26:45 +08:00
parent f1ec32bed0
commit 701c6c39a9
3 changed files with 6 additions and 9 deletions

View File

@ -68,10 +68,10 @@ void InitVertexBuffer()
vb_vertex=CreateVBO(VB2f(3,vertex_data));
vb_color=CreateVBO(VB3f(3,color_data));
va=new VertexArray(2); //两个属性
va=new VertexArray(); ///<创建VAO
const int vertex_location=shader.GetAttribLocation("Vertex"); ///<取得顶点数据输入流对应的shader地址
const int color_location=shader.GetAttribLocation("Color"); ///<取得颜色数据输入流对应的shader地址
const int vertex_location=shader.GetAttribLocation("Vertex"); ///<取得顶点数据输入流对应的shader地址
const int color_location=shader.GetAttribLocation("Color"); ///<取得颜色数据输入流对应的shader地址
va->SetPosition(vertex_location,vb_vertex);
va->AddBuffer(color_location,vb_color);

View File

@ -26,7 +26,7 @@ namespace hgl
public:
VertexArray(GLint max_vertex_attrib);
VertexArray();
~VertexArray();
static int GetMaxVertexAttrib();

View File

@ -18,12 +18,9 @@ namespace hgl
return HGL_MAX_VERTEX_ATTRIBS;
}
VertexArray::VertexArray(GLint max_vertex_attrib)
VertexArray::VertexArray()
{
if(max_vertex_attrib>GetMaxVertexAttrib())
max_vertex_attrib=HGL_MAX_VERTEX_ATTRIBS;
vbo_list.PreMalloc(max_vertex_attrib);
vbo_list.PreMalloc(HGL_MAX_VERTEX_ATTRIBS);
element_buffer=nullptr;