PDA

View Full Version : OpenGL show image from buffer memory leak[SOLVED]



^NyAw^
30th January 2008, 16:21
Hi,

I have a simple application on Windows that takes an image from buffer(char*) and shows it on a QGLWidget.



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);
}
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.

Am I doing something wrong?

I'm new on OpenGL and this is my first application that only shows an image.

Thanks,


[SOLVED]

just force buffer deleting before calling "updateGL".