Draw multiples lines with glVertex3f


#1

Hi everyone! I need your help :frowning:

Im trying to draw multiples lines with glBegin(GL_LINE_STRIP); right?
For this, i have 2 class
1.


Class1::Class1(float x, float y, float z)
    {
        xS  = x;    /* xS is a float */
        yS  = y;    /* yS is a float *
        zS  = z;    /* zS is a float *
    }


Class2::Class2(float x1, float y1, float z1)
    {
        xT  = x1;    /* xT is a float */
        yT  = y1;    /* yT is a float *
        zT  = z1;    /* zT is a float *
    }

Two class have getter and setter methods.
And i have 2 QVector


1. QVector<Class1*> clas1Vector;  /* any object in the vector contain 3 values: x, y, z*/
1. QVector<Class2*> clas2Vector; /* any object in the vector contain 3 values: x1, y1, z1*/

and i have 2 iterator, obviously:


1.
QVector<Class1*>::iterator is;
           for (is = clas1Vector.begin(); is != clas1Vector.end(); ++is)
           {
               x = (*is)->getXS();
               y = (*is)->getYS();
               z = (*is)->getZS();
           }

2.
QVector<Class2*>::iterator it;
           for (it = clas2Vector.begin(); it != clas2Vector.end(); ++it)
           {
               x2 = (*it)->getXT();
               y2 = (*it)->getYT();
               z2 = (*it)->getZT();
           }

okay, now its my question: How can i draw lines with glBegin(GL_LINE_STRIP); without deleting or replacing the previous line? That is, when drawing a new line, the previous one do not erase.
Actually draw the lines so:


glBegin(GL_LINE_STRIP);   
glColor3f(0.0f, 1.0f, 0.0f);     // Green
glVertex3f( x, y, z);
glVertex3f( x2, y2, z2);
glEnd();


#2

Each frame: 1) clear the screen, and 2) draw two line strips instead of one.

Since you’re using the oold “immediate mode” way of registering vertices with OpenGL, put your glBegin()…glEnd() block in a loop and parameterize the vertex positions being registered for each line based on the loop index. Alternatively, copy/paste this block and change the vertex positions sent for the 2nd line.

Also, all the code you posted related to your C++ classes is not relevant to your question.