[PyOpenGL-Users] memory trouble with a very simple program
Brought to you by:
mcfletch
|
From: Champ H. <cha...@be...> - 2003-04-02 12:52:56
|
Hi,
When I run the following program (see below), the memory that is used
by my system (windows XP) as indicated by the task manager is
constantly increasing when I hide and show this PyOpenGL application
with another window (like the task manager for instance). Of course,
the memory increase is not huge (4 Ko at a time in general) but it
does not seem to reach an upper limit. Furthermore, I have the same
problem for another (more complex) application where I refresh the
window with new drawings : in this case the memory trouble gets really
problematic.
What am I doing wrong?
Thanks for your reply.
Bernard
#----------------------------------------------------------------------
from wxPython.wx import *
from wxPython.glcanvas import *
from OpenGL.GL import *
from OpenGL.GLUT import *
class MyCanvasBase(wxGLCanvas):
def __init__(self, parent):
wxGLCanvas.__init__(self, parent, -1)
self.init = False
EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
EVT_SIZE(self, self.OnSize)
EVT_PAINT(self, self.OnPaint)
def OnEraseBackground(self, event):
pass # Do nothing, to avoid flashing on MSW.
def OnSize(self, event):
size = self.GetClientSize()
if self.GetContext():
self.SetCurrent()
glViewport(0, 0, size.width, size.height)
def OnPaint(self, event):
dc = wxPaintDC(self)
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.OnDraw()
class RectangleCanvas(MyCanvasBase):
def InitGL(self):
glMatrixMode(GL_PROJECTION);
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0, 0.0, -2.0);
def OnDraw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.0,0.0,1.0)
glRectf(-0.5,-0.5,0.5,0.5)
self.SwapBuffers()
#----------------------------------------------------------------------
def _test():
class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(None, -1, "Test", wxDefaultPosition,
wxSize(600,300))
win = RectangleCanvas(frame)
frame.Show(True)
##self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
_test()
|