Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to draw lines in Qt3D

    General and Desktop
    1
    2
    1398
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fireking last edited by

      how do I draw lines instead of solid quad in Qt3d.

      I want to use a sceneNode->draw( painter )...

      but sceneNode->setDrawingMode(QGL::Lines) doesn't seem to do anything...

      Looking at example code below, how would I get it to draw lines?

      @
      float vertices[12] =
      {
      -1.0, -1.0, -1.0, // A
      1.0, -1.0, -1.0, // B
      1.0, 1.0, 1.0, // C
      -1.0, 1.0, 1.0 // D
      };
      QGLBuilder quad;
      QGeometryData data;
      data.appendVertexArray(QArray<QVector3D>::fromRawData(
      reinterpret_cast<const QVector3D*>(vertices), 4));
      quad.addQuads(data);
      @

      1 Reply Last reply Reply Quote 0
      • F
        fireking last edited by

        OK, still no luck, reverting to openGL only and all I have are black lines...

        @
        void CubeView::drawGrid()
        {
        int loop1, loop2;
        const int gridSize = 31;

        glColor3f(1.0,0.50,0.50);   // Set my lines colour...
        glLineWidth(2.0);
        glDisable(GL_LINE_SMOOTH);
        
        for ( loop1 =0; loop1<gridSize; loop1++)
        {
            for ( loop2=0; loop2<21; loop2++)
            {
                // Draw Horizontal lines...
                if ( loop1<gridSize-1)
                {
                    glBegin(GL_LINES);
                    glVertex3f(-40+(loop1*5),0.0,-40+(loop2*5));
                    glVertex3f(40+(loop1*5),0.0,-40+(loop2*5));
                    glEnd();
                }
                // Draw vertical lines...
                if (loop2<gridSize-1)
                {
                    glBegin(GL_LINES);
                    glVertex3f(-40+(loop1*5),0.0,-40+(loop2*5));
                    glVertex3f(-40+(loop1*5),0.0,40+(loop2*5));
                    glEnd();
                }
            }
        }
        glFlush();
        

        }
        @

        What am I missing to get coloured lines????

        1 Reply Last reply Reply Quote 0
        • First post
          Last post