From 6c10cd95f94f12c251db1552cd6afd3fbc4c8749 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Thu, 6 Oct 2016 18:48:17 +0100 Subject: [PATCH 1/3] RenderVboIbo: fix number of vertex indices The amount of indices to use from the element buffer is number-of-elements times the number-of-indices. --- include/pangolin/gl/glvbo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pangolin/gl/glvbo.h b/include/pangolin/gl/glvbo.h index c989dfa2a..0897dbca7 100644 --- a/include/pangolin/gl/glvbo.h +++ b/include/pangolin/gl/glvbo.h @@ -127,7 +127,7 @@ inline void RenderVboIbo(GlBuffer& vbo, GlBuffer& ibo, bool draw_mesh) if(draw_mesh) { ibo.Bind(); - glDrawElements(GL_TRIANGLE_STRIP,ibo.num_elements, ibo.datatype, 0); + glDrawElements(GL_TRIANGLE_STRIP, ibo.num_elements*ibo.count_per_element, ibo.datatype, 0); ibo.Unbind(); }else{ glDrawArrays(GL_POINTS, 0, vbo.num_elements); From f8adb129d6af6f4ac4cd0b3e4af2d97b5afbc0a6 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Thu, 6 Oct 2016 19:29:27 +0100 Subject: [PATCH 2/3] RenderVboIbo: use GL_TRIANGLES instead of GL_TRIANGLE_STRIP By using GL_TRIANGLES, the index order does not need to be pre-processed. --- include/pangolin/gl/glvbo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pangolin/gl/glvbo.h b/include/pangolin/gl/glvbo.h index 0897dbca7..d628a1352 100644 --- a/include/pangolin/gl/glvbo.h +++ b/include/pangolin/gl/glvbo.h @@ -127,7 +127,7 @@ inline void RenderVboIbo(GlBuffer& vbo, GlBuffer& ibo, bool draw_mesh) if(draw_mesh) { ibo.Bind(); - glDrawElements(GL_TRIANGLE_STRIP, ibo.num_elements*ibo.count_per_element, ibo.datatype, 0); + glDrawElements(GL_TRIANGLES, ibo.num_elements*ibo.count_per_element, ibo.datatype, 0); ibo.Unbind(); }else{ glDrawArrays(GL_POINTS, 0, vbo.num_elements); From 654cf842691650fdc21c2bf42278b9d3ea6679fb Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 7 Dec 2016 19:38:50 +0000 Subject: [PATCH 3/3] determine drawing mode by IBO count_per_element --- include/pangolin/gl/glvbo.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/pangolin/gl/glvbo.h b/include/pangolin/gl/glvbo.h index d628a1352..18cbce0ed 100644 --- a/include/pangolin/gl/glvbo.h +++ b/include/pangolin/gl/glvbo.h @@ -127,7 +127,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); @@ -173,7 +178,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); @@ -207,7 +217,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);