Results 1 to 1 of 1

Thread: OpenGL show image from buffer memory leak[SOLVED]

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default OpenGL show image from buffer memory leak[SOLVED]

    Hi,

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

    Qt Code:
    1. void QOpenGLWidget::showImage(char* pcData,int iWidth,int iHeight)
    2. {
    3. glClear(GL_COLOR_BUFFER_BIT);
    4.  
    5. glNewList(m_Texture = glGenLists(1), GL_COMPILE);
    6. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    7. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    8. glPixelStorei(GL_UNPACK_ALIGNMENT,1);
    9. glPixelStorei(GL_UNPACK_ROW_LENGTH,0);
    10. glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
    11. glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
    12. glTexImage2D(GL_TEXTURE_2D,0,1,iWidth,iHeight,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pcData);
    13. glEndList();
    14.  
    15. glCallList(m_Texture);
    16.  
    17. glBegin(GL_QUADS);
    18. glTexCoord2f(0.0f, 0.0f);
    19. glVertex2f(0.0f, 0.0f);
    20.  
    21. glTexCoord2f(1.0f, 0.0f);
    22. glVertex2f(float(width()), 0.0f);
    23.  
    24. glTexCoord2f(1.0f, 1.0f);
    25. glVertex2f(float(width()), float(height()));
    26.  
    27. glTexCoord2f(0.0f, 1.0f);
    28. glVertex2f(0.0f, float(height()));
    29. glEnd();
    30. glFlush();
    31.  
    32. GLenum err = glGetError();
    33.  
    34. //force repaint
    35. updateGL();
    36.  
    37. delete[] pcData;
    38. glDeleteLists(m_Texture,1);
    39. }
    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.

    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".
    Last edited by ^NyAw^; 30th January 2008 at 17:35.
    Òscar Llarch i Galán

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.