Created
November 28, 2013 17:21
-
-
Save nkint/7695359 to your computer and use it in GitHub Desktop.
openc2qimage2gltexture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cv::Mat original = //... | |
QImage qtFrame(original.data, original.size().width, original.size().height, original.step, QImage::Format_RGB888); | |
qtFrame = qtFrame.rgbSwapped(); | |
m_GLFrame = QGLWidget::convertToGLFormat(qtFrame); | |
glColor3f(1, 1, 1); | |
glEnable(GL_TEXTURE_2D); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_GLFrame.width(), m_GLFrame.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_GLFrame.bits() ); | |
glBegin(GL_QUADS); | |
int _w=windowWidth, _h=windowHeight/2; | |
glTexCoord2f(0, 1); glVertex2f(0, 0); | |
glTexCoord2f(0, 0); glVertex2f(0, _h); | |
glTexCoord2f(1, 0); glVertex2f(_w, _h); | |
glTexCoord2f(1, 1); glVertex2f(_w, 0); | |
glEnd(); | |
glDisable(GL_TEXTURE_2D); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment