.h
QOpenGLFramebufferObject* m_fbo;
GLuint m_fboColorAttachment;
.cpp
...init code...
m_fbo = new QOpenGLFramebufferObject ( D1_WIDTH, D1_HEIGHT );
glBindFramebuffer ( GL_FRAMEBUFFER, m_fbo->handle () ); // read and write
m_fbo->addColorAttachment ( D1_WIDTH, D1_HEIGHT );
...end init code...
...render loop...
m_fboColorAttachment = m_fbo->takeTexture ();
glBindTexture ( GL_TEXTURE_2D, m_fboColorAttachment );
glTexImage2D ( GL_TEXTURE_2D, // Type of texture
0, // Pyramid level ( for mip-mapping ) - 0 is the top level
GL_RGBA, // Internal colour format to convert to
m_nWidth, // Image width
m_nHeight, // Image height
0, // Border width in pixels ( can either be 1 or 0 )
GL_RGB, //GL_RGB565, // Input image format ( i.e. GL_RGB, GL_RGBA, GL_BGR etc. )
GL_UNSIGNED_SHORT_5_6_5, // Image data type
(char*) m_v4l2Device->pool->buffers[ nIndex ].mem ); // The actual image data itself
//check if OpenGL errors happened
if ( ( enumError = glGetError () ) != GL_NO_ERROR )
{
qDebug ( "OpenGL error: %d.", enumError );
}
.h
QOpenGLFramebufferObject* m_fbo;
GLuint m_fboColorAttachment;
.cpp
...init code...
m_fbo = new QOpenGLFramebufferObject ( D1_WIDTH, D1_HEIGHT );
glBindFramebuffer ( GL_FRAMEBUFFER, m_fbo->handle () ); // read and write
m_fbo->addColorAttachment ( D1_WIDTH, D1_HEIGHT );
...end init code...
...render loop...
m_fboColorAttachment = m_fbo->takeTexture ();
glBindTexture ( GL_TEXTURE_2D, m_fboColorAttachment );
glTexImage2D ( GL_TEXTURE_2D, // Type of texture
0, // Pyramid level ( for mip-mapping ) - 0 is the top level
GL_RGBA, // Internal colour format to convert to
m_nWidth, // Image width
m_nHeight, // Image height
0, // Border width in pixels ( can either be 1 or 0 )
GL_RGB, //GL_RGB565, // Input image format ( i.e. GL_RGB, GL_RGBA, GL_BGR etc. )
GL_UNSIGNED_SHORT_5_6_5, // Image data type
(char*) m_v4l2Device->pool->buffers[ nIndex ].mem ); // The actual image data itself
//check if OpenGL errors happened
if ( ( enumError = glGetError () ) != GL_NO_ERROR )
{
qDebug ( "OpenGL error: %d.", enumError );
}
To copy to clipboard, switch view to plain text mode
Bookmarks