void QOpenGLWidget::showImage(char* pcData,int iWidth,int iHeight)
{
glClear(GL_COLOR_BUFFER_BIT);
glNewList(m_Texture = glGenLists(1), GL_COMPILE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ROW_LENGTH,0);
glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
glTexImage2D(GL_TEXTURE_2D,0,1,iWidth,iHeight,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pcData);
glEndList();
glCallList(m_Texture);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(float(width()), 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(float(width()), float(height()));
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, float(height()));
glEnd();
glFlush();
GLenum err = glGetError();
//force repaint
updateGL();
delete[] pcData;
glDeleteLists(m_Texture,1);
}
void QOpenGLWidget::showImage(char* pcData,int iWidth,int iHeight)
{
glClear(GL_COLOR_BUFFER_BIT);
glNewList(m_Texture = glGenLists(1), GL_COMPILE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ROW_LENGTH,0);
glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
glTexImage2D(GL_TEXTURE_2D,0,1,iWidth,iHeight,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pcData);
glEndList();
glCallList(m_Texture);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(float(width()), 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(float(width()), float(height()));
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, float(height()));
glEnd();
glFlush();
GLenum err = glGetError();
//force repaint
updateGL();
delete[] pcData;
glDeleteLists(m_Texture,1);
}
To copy to clipboard, switch view to plain text mode
The problem is that I'm having memory increasing. The program memory is stable, it increases when the image is loaded and decreased when it is deleted. But the system memory is increasing.
Bookmarks