[webkit-qt] WebGL rendering offscreen

Allan Sandfeld Jensen kde at carewolf.com
Tue Nov 11 06:57:42 PST 2014


On Sunday 09 November 2014, Jorge Fernandez Monteagudo wrote:
> Hi all!
> 
> This is my first message in this list. Maybe this question has been asked
> before several times but I've not been able to find a link with an answer,
> then I go to the source :)
> 
> I'm trying to embed a WebGL page render in my OpenGL application. I've
> develop a little test case using Qt 5.3.2, when I'm able to show a static
> html page rendered in a OpenGL texture in a QGLWidget. This texture comes
> from a QGLFramebufferObject. I use the QWebPage 'repaintRequested' signal
> to do the FBO generation. This is the code:
> 
> QGLFramebufferObject *mp_fbo;
> QWebPage *mp_Page;
> QPainter m_Painter;
> 
> void TGSWebNavigator::onRepaintRequested(const QRect& _rect)
> {
>         ...
>         // Paint the view in the FBO.
>         m_Painter.begin( mp_fbo );
>         mp_Page->mainFrame()->render( &m_Painter, _rect );
>         m_Painter.end();
> 
>         // Repaint QGLWidget with the new FBO.
> }
> 
> If I try to do the same with an URL pointing to a WebGL I get OpenGL
> errors. The problem I think is related to OpenGL contexts because the
> OpenGL widget has his own context and the WebGL rendering is done is
> another one. In a static html page no new context is created when
> rendering is done. I've set several traces to show the current context:
> 
Why are you not using a QGraphicsWebView with a QGLWidget viewport? I would 
recommend that over trying to use the print-preview API in a way that it 
wasn't meant to be used.

Best regards
`Allan


More information about the webkit-qt mailing list