Qt Forum

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

    Qt3D Opacity control on primitives?

    General and Desktop
    1
    2
    1312
    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.
    • F
      fireking last edited by

      How to I set level of opacity when rendering QGLSphere or QGLCube primitives?

      I'm building geometry using QGLBuilder:
      @
      QGLBuilder builder;
      builder << QGL::Faceted;

      if ( currentShape == sphere )
          builder << QGLSphere(0.99,3);  // size of 1, smooth
      else if ( currentShape == cube )
          builder << QGLCube(1.0);  // size of 1, smooth
      
      // Finalise geometry and get QGLSceneNode pointer.
      QGLSceneNode *thisNode = builder.finalizedSceneNode();
      

      @

      1 Reply Last reply Reply Quote 0
      • F
        fireking last edited by

        Figured it out... use alpha blending with color.

        @
        void CubeView::initializeGL(QGLPainter *painter)
        {
        glEnable(GL_BLEND);
        }
        @

        and setAlpha in paintGL...

        @
        QColor colour = QColor(VisualDataItem->getFinalColour());
        colour.setAlpha(127);
        painter->setFaceColor(QGL::AllFaces, colour);

        VisualDataItem->getNode()->draw(painter);
        @

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