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. QGLBuilder and QGLSceneNode help
Forum Update on Monday, May 27th 2025

QGLBuilder and QGLSceneNode help

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.6k 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 use QGLBuilder and QGLSceneNode to add multiple objects to a scene? When I try the code below app expectedly quits...

    QGLBuilder builder;
    QGLSceneNode *node;
    builder << QGL::Faceted;
    builder << QGLSphere(2,4);
    root = builder.finalizedSceneNode();
    builder << QGLCube();
    node = builder.finalizedSceneNode();
    root->addNode(node);

    Thanks.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fireking
      wrote on last edited by
      #2

      ...after further reading the following produces a blank screen:
      @
      CubeView::CubeView(QWindow *parent)
      : QGLView(parent)
      {
      // here a top level node for the app is created, and parented to the view
      topNode = new QGLSceneNode(this);

      QGLBuilder b1;
      // build geometry
      b1 << QGL::Faceted;
      b1 << QGLSphere(2,4);
      
      thing = b1.finalizedSceneNode();
      
      // does a QObject::setParent() to manage memory, and also adds to the scene
      // graph, so no need to call topNode->addNode(thing)
      thing->setParent(topNode);
      
      QGLBuilder b2;
      // build more geometry
      b2 << QGLCube();
      
      anotherThing = b2.finalizedSceneNode();
      
      // again parent on get addNode for free
      anotherThing->setParent(topNode);
      

      @
      }

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fireking
        wrote on last edited by
        #3

        ...working now, changed CubeView::paintGL to only draw child nodes for now...

        @
        void CubeView::paintGL(QGLPainter *painter)
        {
        painter->setStandardEffect(QGL::LitMaterial);
        painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));

        painter->modelViewMatrix().rotate(45.0f,1.0f,1.0f,1.0f);
        thing->draw(painter);
        
        QMatrix4x4 mat;
        mat.translate( 2.0f, 0.0f, -2.0f);
        anotherThing->setLocalTransform(mat);
        anotherThing->draw(painter);
        

        }
        @

        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