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

  • 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 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);
    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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.