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. How can I use QGLFramebufferObject for render-to-texture without using QPainter
Forum Updated to NodeBB v4.3 + New Features

How can I use QGLFramebufferObject for render-to-texture without using QPainter

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

    Hi all,

    I'm new to QT. I want to combine my game engine with QT for multi-platform use.

    The other part of my graphic was done by OpenGL only, I don't want to let QPainter to render on screen or on render targets. I also want to include "qgl.h" only without depending on another gl lib. I found glGenFramebuffers is not defined although my target machines should have this feature.

    So how can I render to the FBO created by *QGLFramebufferObject * without using QPainter? The only example that I found relatively was http://qt-project.org/doc/qt-4.8/opengl-framebufferobject-glwidget-cpp.html which used QPainter.

    Another problem that I met was I detected memory leaks in using QImage to load pngs and turning it to GL format. My code is like
    @
    QImage qimg;
    qimg.loadFromData((BYTE*)data, _size);
    QImage qimg_gl = QGLWidget::convertToGLFormat(qimg);
    if (qimg_gl.isNull())
    {
    return NULL;
    }
    glGenTextures(1, &pTex);
    if (pTex) {
    glBindTexture(GL_TEXTURE_2D, pTex);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, qimg_gl.width(), qimg_gl.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, qimg_gl.bits());
    }
    @
    Later I called glDeleteTextures for releasing. However, I tracked something created by QT caused memory leak. Do I need to call somthing like qimg_gl.Free to avoid leaking? My BYTE*data was deleted correctedly.

    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