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. [SOLVED] OpenGL lists does not work in custom QGraphicsItem's paint() with plain QGLWidget
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] OpenGL lists does not work in custom QGraphicsItem's paint() with plain QGLWidget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 4.1k 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.
  • T Offline
    T Offline
    takbal
    wrote on last edited by
    #1

    The documentation says that you can use OpenGL commands anywhere until you do a makeCurrent() for the QGLWidget. I still cannot make an OpenGL list show anything from a custom QGraphicsItem's paint() function. The OpenGL m_List of GL_POINTS is created in the constructor, and the paint function is the following:

    @void Points::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * widget)
    {
    if (painter->paintEngine()->type() != QPaintEngine::OpenGL &&
    painter->paintEngine()->type() != QPaintEngine::OpenGL2 )
    { return; }

    QGLWidget* glwidget = dynamic_cast<QGLWidget*>(widget);
    glwidget->makeCurrent();
    // glwidget->renderText(2000,3000,10,"whatever"); // does not work either

        glCallList(m_List); // does not work
    

    }
    @

    The widget does not show anything. Doing plain painter->draw...() functions do work.

    Other examples where OpenGL commands issued in a customized QGLWidget do work correctly. Can anybody point me an example where plain OpenGL is used outside that class for displaying in a QGLWidget?


    EDIT: found the answer. 4.6 introduced the QPainter::beginNativePainting() and QPainter::endNativePainting() functions. With those it works fine. More about the topic:

    http://labs.trolltech.com/blogs/2010/01/06/qt-graphics-and-performance-opengl/

    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