增加硬件最大顶点属性取值和处理
This commit is contained in:
parent
af9cf59191
commit
6511c6615b
@ -15,7 +15,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int vao;
|
GLuint vao;
|
||||||
|
|
||||||
uint primitive; ///<绘制的图元类型
|
uint primitive; ///<绘制的图元类型
|
||||||
|
|
||||||
@ -40,6 +40,8 @@ namespace hgl
|
|||||||
VertexArray(uint prim,uint max_vertex_attrib);
|
VertexArray(uint prim,uint max_vertex_attrib);
|
||||||
~VertexArray();
|
~VertexArray();
|
||||||
|
|
||||||
|
static int GetMaxVertexAttrib();
|
||||||
|
|
||||||
uint GetPrimitive ()const{return primitive;} ///<取得要绘制的图元类型
|
uint GetPrimitive ()const{return primitive;} ///<取得要绘制的图元类型
|
||||||
|
|
||||||
public: //通用顶点缓冲区设置
|
public: //通用顶点缓冲区设置
|
||||||
@ -61,6 +63,7 @@ namespace hgl
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
int GetDrawCount (); ///<取得可绘制的数据总数量
|
int GetDrawCount (); ///<取得可绘制的数据总数量
|
||||||
|
bool Draw(); ///<绘制
|
||||||
};//class VertexArray
|
};//class VertexArray
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -5,8 +5,24 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static int HGL_MAX_VERTEX_ATTRIBS=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VertexArray::GetMaxVertexAttrib()
|
||||||
|
{
|
||||||
|
if(HGL_MAX_VERTEX_ATTRIBS<=0)
|
||||||
|
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,&HGL_MAX_VERTEX_ATTRIBS);
|
||||||
|
|
||||||
|
return HGL_MAX_VERTEX_ATTRIBS;
|
||||||
|
}
|
||||||
|
|
||||||
VertexArray::VertexArray(uint prim,uint max_vertex_attrib)
|
VertexArray::VertexArray(uint prim,uint max_vertex_attrib)
|
||||||
{
|
{
|
||||||
|
if(max_vertex_attrib>GetMaxVertexAttrib())
|
||||||
|
max_vertex_attrib=HGL_MAX_VERTEX_ATTRIBS;
|
||||||
|
|
||||||
primitive=prim;
|
primitive=prim;
|
||||||
|
|
||||||
vertex_buffer_list.PreMalloc(max_vertex_attrib);
|
vertex_buffer_list.PreMalloc(max_vertex_attrib);
|
||||||
@ -90,5 +106,18 @@ namespace hgl
|
|||||||
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VertexArray::Draw()
|
||||||
|
{
|
||||||
|
if(element_buffer)
|
||||||
|
glDrawElements(primitive,0,element_buffer->GetCount(),element_buffer->GetDataType(),nullptr);
|
||||||
|
else
|
||||||
|
if(vertex_buffer)
|
||||||
|
glDrawArrays(primitive,0,vertex_buffer->GetCount());
|
||||||
|
else
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user