# Using an array of 3d points to construct point cloud or surface in OpenGL

I have an array of 3 dimensional point objects, I can manipulate the input into this array into any configuration I want, for example, it could be a vector of floating point numbers, a vector of ints, etc.

Anyway, I want to display this 3d point cloud using OpenGL. How should I go about doing this? I know enough that I can create a 3d cube from structured inputs but how would I go about creating vertices from this unstructured input? If I don't need to construct these vertices how would I go about simply displaying these points as a cloud? Any suggestions or advice is welcome.

• how would I go about creating vertices from this unstructured input? What does this mean? Your input has to be in some structure, otherwise it is just some random garbage and will look like random triangles if you draw it Commented Aug 10, 2015 at 7:47
• @tkausl my apologies, it isn't structured as in they aren't already vertices. Commented Aug 10, 2015 at 7:49
• So what are they? Commented Aug 10, 2015 at 7:56
• @tkausl just something like Point(x,y,z), simply data points. They aren't structured such that they can be pushed into something like a vertex buffer, right? Commented Aug 10, 2015 at 7:59
• What, you mean it is literally a textfile containing lines with Point(1, 2, 3) or what? Commented Aug 10, 2015 at 8:13

As stated in the comments, drawing points is as simple as drawing GL_POINTS instead of GL_TRIANGLES, you'll need one vertex instead of three of course.

TLDR: Since you already know how to draw triangles or a cube (which itself is just built out of multiple triangles), you already know how the data looks OpenGL-expects and how to draw. So all you need to do now is convert your input data to the same format and draw your GL_POINTS.
The simplest solution to this would be simply buffering the vertices into a VBO like you normally do, then rendering them as GL_POINTS instead of GL_TRIANGLES or GL_TRIANGLE_STRIP.
While technically you could do the same with the built-in GL_POINTS approach, it is not supported properly by drivers in my experience, so you have to resort to your own geometry shader.