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. Using QGLTwoSidedMaterial vs QGLMaterial
Qt 6.11 is out! See what's new in the release blog

Using QGLTwoSidedMaterial vs QGLMaterial

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

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

      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
      0

      • Login

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