matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
494 stars 71 forks source link

incorrect indices for Plane #38

Closed ghost closed 10 years ago

ghost commented 10 years ago

the indices array returned of the plane shape contains indices for points which are not in the positions array

with the default udiv(2) and vdiv(2) the index 14 is contained in the index array although there are only 9 points / 27 floats

i think the bug is in plane.ipp line 32: indices[k++] = pri; you probably meant the last point whereas pri is the number of indices.

matus-chochlik commented 10 years ago

Hi,

'pri' stands for Primitive Restart Index, it is a value that which when found in the index array restarts the currently drawn primitive. The plane is drawn using the GL_TRIANGLE_STRIP primitives, and the strips are oriented in the direction of the plane's u-axis and each such strip is restarted by the PRI. This allows to draw the plane using a single glDrawElements call instead of one call-per-strip, which is much more efficient. The PRI has to be a value that is not 'normally' found in the index array.

So unless I'm overlooking something, this is a feature not a bug :)

ghost commented 10 years ago

Ok, thanks. Did not know about this opengl feature.