QUItCoding / qnanopainter

Library for implementing OpenGL accelerated Qt (Quick) C++ UI components.
http://quitcoding.com
Other
405 stars 79 forks source link

Renderer into fbo in none-ui thread #86

Open evehal opened 4 months ago

evehal commented 4 months ago

I can use QPainter in multiple threads like this: glBindFramebuffer(GL_FRAMEBUFFER, m_fbos[buffer_idx]); QOpenGLPaintDevice fboPaintDev(t.w,t.h); glBindTexture(GL_TEXTURE_2D, m_textures[buffer_idx]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, t.w, t.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glBindTexture(GL_TEXTURE_2D,0); m_painter.begin(&fboPaintDev); m_painter.fillRect(0, 0, t.w, t.h, QColor(0, 0, 0, 0)); m_painter.end(); glBindFramebuffer(GL_FRAMEBUFFER, 0);

how to work with qnanopainter in multiple none-ui threads?

mariuszmaximus commented 4 months ago

@evehal Can you show a complete example of your code? I am interested in this subject (QPainter in multiple threads)

evehal commented 4 months ago

@mariuszmaximus my project too big to show,sorry mate. but qpainters in multiple thread is very common: https://doc.qt.io/qt-6/threads-modules.html and for opengl offscreen render: https://stackoverflow.com/questions/31323749/easiest-way-for-offscreen-rendering-with-qopenglwidget fbo is the key.