Qt Forum

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

    Using QGLTwoSidedMaterial vs QGLMaterial

    General and Desktop
    2
    2
    851
    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.
    • Q
      quantumavatar last edited by

      So using QGLMaterial is pretty straight forward. This works fine for me:

      @
      QGeometryData plot1;
      QGLSceneNode *node1 = builder.newNode();

      QVector3D a1( 0,  0,   0 ); plot1.appendVertex(a1);
      ...
      QVector3D h1( 3,  1.5, 0 ); plot1.appendVertex(h1);
      builder.addQuadStrip(plot1);
      
      QGLMaterial *mat1 = new QGLMaterial;
      mat1->setColor(Qt::green);
      node1->setMaterial(mat1);
      node1->setEffect(QGL::LitMaterial);@
      

      However I have not seen any tutorials or examples of using two sided material so I tried this:

      @ QGLMaterial *mat1 = new QGLMaterial;
      mat1->setColor(Qt::green);

      QGLTwoSidedMaterial *ts = new QGLTwoSidedMaterial;
      ts->setFront(mat1);
      ts->setBack(mat1);
      
      node1->setMaterial(ts);
      node1->setEffect(QGL::LitMaterial);@
      

      but I get an error

      @error: no matching function for call to 'QGLSceneNode::setMaterial(QGLTwoSidedMaterial*&)'@

      How exactly do you utilize the two sided material? I dont see it used in the Qt3D examples or the API page.

      You guys rock!

      Long Live Qt!

      1 Reply Last reply Reply Quote 0
      • T
        tonyorourke last edited by

        Had the same problem. Solved it by binding the material to the painter in the node's draw(QGLPainter *painter) routine. Try this -

        ts->bind(painter);
        .... (other code) ...
        ts->release(painter, 0);

        QGLTwoSidedMaterial is derived from QGLAbstractMaterial, not from QGLMaterial, so setMaterial(ts) won't work.

        Hope this helps.

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