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. OpenGl Overlaid with QPainter

OpenGl Overlaid with QPainter

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 454 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.
  • E Offline
    E Offline
    epalmero
    wrote on 29 Jan 2015, 12:19 last edited by
    #1

    Dear All:

    I am using the new Qt5.4 and I need to do some overlaid of OpenGL draw with the normal QPainter draw. I have override the @paintEvent@ function and I have writting the following code:

    @QPainter painter;
    painter.begin(this);

    makeCurrent();
    paintGL();
    
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);
    glViewport(0, 0, this->width(), this->height());
    
    QPen pen;
    pen.setColor(Qt::white);
    painter.setPen(pen);
    painter.fillRect(QRectF(10.0, 10.0, 50, 50), Qt::red);
    //painter.drawText(QRectF(10.0, 10.0, 50, 50), Qt::AlignCenter, "Pepe");
    painter.end();@
    

    in the paintGL function I have:

    @ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (auto &scene : renderScenes_)
            scene->paint();@
    

    which is where I draw the OpenGl stuff. For some reason I don't arrive to see the fillRect except if I remove the @for (auto &scene : renderScenes_)
    scene->paint();@ part. I don't know why because I am just sending normal openGl commands there. Is there anything that I have to paid specal attention?

    All the best
    Ernesto

    1 Reply Last reply
    0

    1/1

    29 Jan 2015, 12:19

    • Login

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