huseyin tugrul buyukisik
huseyin tugrul buyukisik

Reputation: 11920

Is there a shaderless way to draw multiple points with different sizes using glDrawArrays()?

I'm drawing a point cloud with different colors of points with this:

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);


    glVertexPointer(3, GL_FLOAT, 0, vertices.get());
    glColorPointer(3, GL_FLOAT, 0, colors.get());


    glDrawArrays(GL_POINTS, 0, n);


    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

is there a way to tell glDrawArrays (or the default shader) to use another client state for size of each point?

Upvotes: 1

Views: 635

Answers (1)

Zedwa92
Zedwa92

Reputation: 137

If there was, that would be terribly inefficient!

  1. Use the programmable pipeline, in a core context => OpenGL 3.3 and above.
  2. Create a buffer with all your vertices (your points).
  3. Create a buffer with the sizes of each point.
  4. Pass buffers 2 and 3 to your vertex shader. Assign the size to the global gl_PointSize.

If you don't get what I am suggesting, you must then begin by learning the modern OpenGL way of rendering :)

Upvotes: 2

Related Questions