PDA

View Full Version : Qt5.3.2. Embeeded OpenGL web browser using QWebPage fails opening WebGL pages



josema
5th November 2014, 12:07
Hi all,

I've an embeeded opengl web browser using Qt5.3.2 QWebPage (not using QWebView). Everything is working fine for normal pages, but when I try to render a WebGL page I got an error while updating opengl texture from QPainter image:

void MyWebPage::onRepaintRequested (const QRect& _rect)
{
....

// paint frame
m_Painter.begin (&m_Image);

mainFrame ()->render (&m_Painter, _rect);

m_Painter.end ();

// update opengl texture
glBindTexture (GL_TEXTURE_2D, GetTextureId());

int32_t y = m_Image.height() - (_rect.y() + _rect.height());

glPushClientAttrib (GL_CLIENT_PIXEL_STORE_BIT );
glPixelStorei (GL_UNPACK_ROW_LENGTH, m_Image.bytesPerLine() / 4);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, _rect.x());
glPixelStorei (GL_UNPACK_SKIP_ROWS, y);
glTexSubImage2D (GL_TEXTURE_2D, 0, _rect.x(), y, _rect.width(), _rect.height(), GL_BGRA, GL_UNSIGNED_BYTE, m_Image.bits ());
glPopClientAttrib ();

....
}

Concretely, I'm receiving a GL_INVALID_VALUE error in the glTexSubImage2D

I've checked it, and rectangle position and dimensions send to glTexSubImage2D functions are ok.

The error disappears when a rectangle with dimensions less or equal to one is sent to the function. It seems like if texture being updated was deleted or its dimensions are null, but I've also checked it and it's ok.

When I save the WebGL page image generated by QPainter it looks good, so QWebPage and QPainter are working ok.

I guess the problem is having opengl and webgl at the same time, but I've no idea about how to fix the problem... so any help will be welcomed.

Thanks in advance!