After days of trying I was not able to render Pixeldata into a textured quad correctly.
What I want is fairly simple (I think): I am currently writing a VNC implementation for my company to bind it into an existing application. I already successfully implemented the RfbProtocol (at least as far as I need it) and I am able to get the correct Pixeldata. Because the VNC server is sending incremental changes only I am receiving small rectangles with the changed region and the pixel information.
I already worked out that the corresponding OpenGL Formats for the Pixeldata is GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV.
Because I was not able to use Textured Quads (whats seems to be the optimal implementation for this purpose) I used a different approach:
if(m_queue.size() > 0)
{
if (!m_fbo || m_fbo->size() != size())
{
delete m_fbo;
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
m_fbo = new QOpenGLFramebufferObject(size());
}
m_fbo->bind();
Q_FOREACH (RfbProtocol::RfbRectangle rect, m_queue.dequeue().rectangles())
{
glViewport(0, 0, 1920, 1080);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1920, 0, 1080, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos2d(rect.xpos, rect.ypos);
glDrawPixels(rect.width,rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, rect.pixelData.data());
}
m_fbo->release();
this->update();
}
This is all done inside an QOpenGLWidget.
Obviously this is not the best approach but it is working for testing. The problem is that I need to scale the Pixeldata to the size of the Widget, which would work nicely together with a OpenGLTexture but as I mentioned at the beginning I simply wasn't able to do it correctly.