You can either report a bug and/or try to reuse the same texture for a new pixmap (I understand the problem is that the pixmap changes which causes memory usage to grow) and draw directly using GL code.
You can either report a bug and/or try to reuse the same texture for a new pixmap (I understand the problem is that the pixmap changes which causes memory usage to grow) and draw directly using GL code.
Thanks,
I reported a bug to trolltech last week about that.
But I can't reuse the same GL texture as I don't have access to it.
For now i just don't use a QPainter to draw on QGLWidgets. I draw everything I need in an offscreen QPixmap and then use my own code to upload and draw it with OpenGL.
I'll post here references to the bug I reported if any are interested.
What do you mean you don't have access to it? So what calls BindTexture()?
Qt does.
I never dealt directly with OpenGL. I just used the QPainter and drawPixmap().
Internally drawPixmap() creates GL textures for each of my QPixmap and store them in the cache. Whenever a QPixmap is modified, a new GL texture is associated to it. When the cache hits its size limit, Qt deletes GL textures but as my GL context is shared, glDeleteTexture() is never called (but the Qt wrapper around GL textures is deleted from the cache).
Basically this is what I was doing :
Qt Code:
{ // my overlays are QPixmaps // some of them can be updated often for_each_of_my_overlays() { // this will internally create a GL texture for the QPixmap // reusing the texture if the QPixmap is the same (cache system) l_Painter->drawPixmap(l_Overlay); } }To copy to clipboard, switch view to plain text mode
I hope I'm clear enough
edit: I think I understand what you mean. I don't use QGLWidget::bindTexture() neither QGLContext::bindTexture() but I noticed in the docs that if the context is shared the GL texture won't be destroyed. But in my case, Qt creates GL texture, not me.
Last edited by bamboo; 16th April 2007 at 10:46.
Ok, but this is an overlay. You do have some actual GL code underneath. So you can make a plane, place it orthogonal to the screen and instead of using QPainter simply apply a texture to the plane.
Yep, that's what I do now to overcome this
But using QPainter would have been "cleaner" and easier for me as it is designed fot this.
Anyway I reported the bug to Trolltech as I don't think this is a normal behavior ...
Thanks !
Hi again,
for those who might be interested, the bug has been verified by Qt's team and has been assigned #158971.
http://www.trolltech.com/developer/t...ntry&id=158971
Have a nice day !
Bookmarks