Image processing in OpenGL



  • Hello.
    I want to process the image and save it. Wrote this code, but the output is a black image. What am I doing wrong?

    void ImageProcessor::startProcessing()
    {
        QSurfaceFormat surFormat;
    
        QOpenGLContext context;
        context.setFormat(surFormat);
    
        if(!context.create())
            return;
    
        QOffscreenSurface surface;
        surface.setFormat(surFormat);
        surface.create();
    
        if(!context.makeCurrent(&surface))
            return;
    
        auto func = QOpenGLContext::currentContext()->functions();
    
        QOpenGLFramebufferObjectFormat format;
        format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
    
        QOpenGLFramebufferObject fbo(1000, 1000, format);
    
        fbo.bind();
    
        func->glClearColor(0, 0, 0, 1);
    
        QOpenGLTexture *texture = new QOpenGLTexture(m_imageIn.mirrored(), 
        QOpenGLTexture::MipMapGeneration::DontGenerateMipMaps);
        if(!texture->create())
            return;
        texture->bind();
        texture->release();
    
        fbo.release();
    
        m_imageOut = fbo.toImage();
    
        emit finishProcessing();
    }
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Where are you calling this code from ?


Log in to reply
 

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