View Full Version : NaN values and glDrawArrays

08-01-2013, 08:26 AM
Hi, here's my question.

I've this OpenGL code working:

glVertexPointer( 3, GL_FLOAT, sizeof(MGVPoint), &(pts->x) );
glColorPointer ( 4, GL_UNSIGNED_BYTE, sizeof(MGVPoint), &(pts->r) );
glDrawArrays ( GL_TRIANGLE_STRIP, 0, points.size() );

As you can understand I want to plot several triangles using an array of <MGVPoint> which is a structure containing the 3 (x, y, z) coordinates in float and the colour as an unsigned byte.
This code is working fine but when I have a nan value as one of the coordinates.
Since I can't modify the source vector and I wish to avoid to draw it point-by-point, is there any way to automatically avoid to plot the points which have a nan value as one of the coordinates?

Thanks in advance,

carsten neumann
08-01-2013, 09:03 AM
I'd say you'll have to make a copy of the data where the invalid entries are filtered out or you could use indexed drawing (i.e. glDrawElements) and use the index to never pass the invalid entries to OpenGL.

08-01-2013, 09:11 AM
That's a mess... I was trying to avoid any copy because the render is already slow enough :dejection:.
I'll try with the indexed drawing, but I think that with vectors of hundred of thousands or more elements containing only few "nan" it would be pretty slow too.

Anyway thanks for the quick answer!