Trouble porting some GL line strips to core profile

45 views Asked by At

I have to port some legacy OpenGL code to the 3.3+ core profile (which I'm only somewhat familiar with) but there's a specific section I'm having some trouble with because the only way I can think to do involves a pretty inflated amount of code.

Basically, I have this:

def lines (*points):
    glBegin(GL_LINE_STRIP)
    for p in points:
        glVertex3fv(p)
    glEnd()

glLineWidth(1)
for camera in self._cameras.values():
    for b in camera.cameraPparts.values():
        lines(b.head, b.neck, b.center)
        lines(b.neck, b.lshoulder, b.lelbow, b.lwrist)
        lines(b.neck, b.rshoulder, b.relbow, b.rwrist)
        lines(b.center, b.lhip, b.lknee, b.lankle)
        lines(b.center, b.rhip, b.rknee, b.rankle)

That is, I draw a bunch of multi-segment lines, using GL_LINE_STRIP.

Each strip is a separate poly-line, so its five line strips in total. Also there are three "cameras" in that loop so it's really 15 line strips in total.

The only way I know how to do this with what I know so far of the core profile is:

  1. Create 15 separate VAO's
  2. Create a VBO for each (15 times)
  3. Load each poly-line into its own VBO (15 times)
  4. glDrawArray for each VBO (15 times)

Which seems like a ton of code and data management for five lines.

Is there a smoother, less verbose way to make this happen?

I have a similar problem with some GL_LINE_LOOPs elsewhere, too, so anything here can apply to that as well.

0

There are 0 answers