Skip to content

Commit

Permalink
determine drawing mode by IBO count_per_element
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rauch committed Dec 7, 2016
1 parent 584650d commit a561efc
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions include/pangolin/gl/glvbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ inline void RenderVboIbo(GlBuffer& vbo, GlBuffer& ibo, bool draw_mesh)

if(draw_mesh) {
ibo.Bind();
glDrawElements(GL_TRIANGLES, ibo.num_elements*ibo.count_per_element, ibo.datatype, 0);
if(ibo.count_per_element==1) {
glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0);
}
else {
glDrawElements(GL_TRIANGLES,ibo.num_elements*ibo.count_per_element, ibo.datatype, 0);
}
ibo.Unbind();
}else{
glDrawArrays(GL_POINTS, 0, vbo.num_elements);
Expand Down Expand Up @@ -177,7 +182,12 @@ inline void RenderVboIboCboNbo(GlBuffer& vbo, GlBuffer& ibo, GlBuffer& cbo, GlBu

if(draw_mesh) {
ibo.Bind();
glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0);
if(ibo.count_per_element==1) {
glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0);
}
else {
glDrawElements(GL_TRIANGLES,ibo.num_elements*ibo.count_per_element, ibo.datatype, 0);
}
ibo.Unbind();
}else{
glDrawArrays(GL_POINTS, 0, vbo.num_elements);
Expand Down Expand Up @@ -211,7 +221,12 @@ inline void RenderVboIboNbo(GlBuffer& vbo, GlBuffer& ibo, GlBuffer& nbo, bool dr

if(draw_mesh) {
ibo.Bind();
glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0);
if(ibo.count_per_element==1) {
glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0);
}
else {
glDrawElements(GL_TRIANGLES,ibo.num_elements*ibo.count_per_element, ibo.datatype, 0);
}
ibo.Unbind();
}else{
glDrawArrays(GL_POINTS, 0, vbo.num_elements);
Expand Down

0 comments on commit a561efc

Please sign in to comment.