Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: NaN values and glDrawArrays

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2

    Question NaN values and glDrawArrays

    Hi, here's my question.

    I've this OpenGL code working:
    Code :
            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,
    GortiZ

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    741
    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.

  3. #3
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2
    That's a mess... I was trying to avoid any copy because the render is already slow enough .
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •