Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Adding color to QGLBuilder object
Qt 6.11 is out! See what's new in the release blog

Adding color to QGLBuilder object

Scheduled Pinned Locked Moved Game Development
2 Posts 1 Posters 1.0k 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.
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #1

    I am learning QT. I can successfully add multiple nodes to my scene. I want to give a color to each of the builder objects. I can add color to the whole node using:
    painter->setStandardEffect(QGL::LitMaterial);
    But how to color a single builder object? WI use the following code.

    @QGLBuilder builder;
    builder << QGL::Faceted;
    builder << QGLCube();
    QGLMaterial *cubematerial= new QGLMaterial;
    cubematerial->setColor(Qt::red);
    builder.palette(cubematerial);
    cube = builder.finalizedSceneNode();@

    It gives me an error:
    :57: error: no matching function for call to 'QGLBuilder::palette(QGLMaterial*&)'
    builder.palette(cubematerial);
    ^
    What does it mean. Also, if I need to change the position of the cube, what should I do? Thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sunil.nair
      wrote on last edited by
      #2

      Hey, i figured it out. You just need to change the painter properties and set it to the new node. @painter->setStandardEffect(QGL::LitMaterial);
      painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
      cube->draw(painter);
      painter->setFaceColor(QGL::AllFaces, QColor(200, 202, 0));
      trident->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