Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to draw lines in Qt3D

How to draw lines in Qt3D

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.5k Views
  • 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 Offline
    F Offline
    fireking
    wrote on last edited by
    #1

    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
    0
    • F Offline
      F Offline
      fireking
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved