Support binding gfx::mesh
This commit is contained in:
parent
d9f06efb57
commit
131f06b012
2 changed files with 12 additions and 5 deletions
|
|
@ -115,6 +115,8 @@ namespace psemek::gfx
|
|||
mesh(mesh const &) = delete;
|
||||
mesh & operator = (mesh const &) = delete;
|
||||
|
||||
void bind() const;
|
||||
|
||||
void setup(attribs_description const & attribs);
|
||||
|
||||
template <typename ... Attribs>
|
||||
|
|
|
|||
|
|
@ -29,11 +29,16 @@ namespace psemek::gfx
|
|||
return *this;
|
||||
}
|
||||
|
||||
void mesh::bind() const
|
||||
{
|
||||
array_.bind();
|
||||
}
|
||||
|
||||
void mesh::setup(attribs_description const & attribs)
|
||||
{
|
||||
assert(!attribs.attribs.empty());
|
||||
|
||||
array_.bind();
|
||||
bind();
|
||||
|
||||
for (std::size_t i = 0; i < info_.max_attribute_index_; ++i)
|
||||
gl::DisableVertexAttribArray(i);
|
||||
|
|
@ -108,7 +113,7 @@ namespace psemek::gfx
|
|||
|
||||
if (count != 0 && instance_count != 0)
|
||||
{
|
||||
array_.bind();
|
||||
bind();
|
||||
gl::DrawElementsInstanced(primitive_type(), count, index_type(), reinterpret_cast<char const *>(detail::index_size(index_type()) * first), instance_count);
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +121,7 @@ namespace psemek::gfx
|
|||
{
|
||||
if (count != 0)
|
||||
{
|
||||
array_.bind();
|
||||
bind();
|
||||
gl::DrawElements(primitive_type(), count, index_type(), reinterpret_cast<char const *>(detail::index_size(index_type()) * first));
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +136,7 @@ namespace psemek::gfx
|
|||
|
||||
if (count != 0 && instance_count != 0)
|
||||
{
|
||||
array_.bind();
|
||||
bind();
|
||||
gl::DrawArraysInstanced(primitive_type(), first, count, instance_count);
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +144,7 @@ namespace psemek::gfx
|
|||
{
|
||||
if (count != 0)
|
||||
{
|
||||
array_.bind();
|
||||
bind();
|
||||
gl::DrawArrays(primitive_type(), first, count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue