[PyOpenGL-Users] OpenGL Error
Brought to you by:
mcfletch
From: <sh...@lo...> - 2007-10-23 01:34:25
|
Hi again, I think I may have fixed my earlier error by changing my Python path (again), but now I get another error. Again, this software works on a different Linux system, but I'm having trouble with it on this one. Does anyone have any ideas for me? Thanks again! Shari Here is the error message: ============================================ Traceback (most recent call last): File "/home/shari/workspace/VisualizationGallery20071022/src/gui/wxGui.py", line 72, in <module> vizApp = VizApp() File "/home/shari/workspace/VisualizationGallery20071022/src/gui/wxGui.py", line 10, in __init__ wx.App.__init__(self, redirect=False) File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-ansi/wx/_core.py", line 7818, in __init__ self._BootstrapApp() File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-ansi/wx/_core.py", line 7415, in _BootstrapApp return _core_.PyApp__BootstrapApp(*args, **kwargs) File "/home/shari/workspace/VisualizationGallery20071022/src/gui/wxGui.py", line 33, in OnInit self.win = mainWindow.mainWindow(frame) File "/home/shari/workspace/VisualizationGallery20071022/src/gui/mainWindow.py", line 30, in __init__ self.navigationWin.setPosition(navigationWindow.Position(0, 0)) File "/home/shari/workspace/VisualizationGallery20071022/src/gui/navigationWindow.py", line 163, in setPosition self.gallery.LookAt(self.position.x, self.position.z) File "/home/shari/workspace/VisualizationGallery20071022/src/gui/gallery.py", line 145, in LookAt billboardX, billboardY, billboardZ) File "/home/shari/workspace/VisualizationGallery20071022/src/gui/gallery.py", line 130, in SetPosition self.OnDraw() File "/home/shari/workspace/VisualizationGallery20071022/src/gui/gallery.py", line 115, in OnDraw glCallList(self.billboardList) File "build/bdist.linux-i686/egg/OpenGL/error.py", line 188, in glCheckError OpenGL.error.GLError: GLError( err = 1281, description = 'invalid value', baseOperation = glCallList, cArguments = (1L,) ) ============================================ And here is the offending class: ============================================ #!/usr/bin/env python2.4 import wx import os import Image import glMethods import wx.lib.scrolledpanel as scrolled import wx.lib.statbmp as statbmp import wx.lib.buttons as buttons from wx import glcanvas from vtk.wx.wxVTKRenderWindow import * from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * import vizGenerator.vizEngine MAP_FILE_NAME = "/home/shari/thesisFiles/testSet.cod" DATA_FILE_NAME = "/home/shari/thesisFiles/schoolData.vtk" MAX_HISTORY_SIZE = 1000 class myGLWindow(glcanvas.GLCanvas): def __init__(self, parent): glcanvas.GLCanvas.__init__(self, parent, -1) print "In myGLWindow.__init__" self.init = False # initial mouse position self.lastx = self.x = 30 self.lasty = self.y = 30 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMouseMotion) self.InitGL() def OnEraseBackground(self, event): pass # Do nothing, to avoid flashing on MSW. def OnSize(self, event): print "In myGLWindow.OnSize" self.SetCurrent() size = self.GetClientSize() if self.GetContext(): self.SetCurrent() if (True): if (size.height == 0): size.height = 1 # prevent divide by 0 glViewport(0, 0, size.width, size.height) glMatrixMode(GL_PROJECTION) glLoadIdentity() # Calculate the aspect ratio of the window # gluPerspective(80.0, float(size.width) / float(size.height), # 1.0, 50.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() #self.SwapBuffers() self.OnDraw() event.Skip() def OnPaint(self, event): dc = wx.PaintDC(self) self.SetCurrent() if not self.init: self.InitGL() self.init = True self.OnDraw() def OnMouseDown(self, evt): self.CaptureMouse() def OnMouseUp(self, evt): self.ReleaseMouse() def OnMouseMotion(self, evt): if evt.Dragging() and evt.LeftIsDown(): self.x, self.y = self.lastx, self.lasty self.x, self.y = evt.GetPosition() self.Refresh(False) class Gallery(myGLWindow): vizImageIds = [] #global myVizEngine xMapSize = 0 yMapSize = 0 width = 1.0 # Length of a billboard height = 1.0 # Height of a billboard distX = 1.0 # Distance between billboards in the x direction distZ = 1.5 # Distance between billboards in the z direction myVizEngine = vizGenerator.vizEngine.vizEngine(MAP_FILE_NAME, DATA_FILE_NAME) xMapSize = int(myVizEngine.mapMatrix.sizeX) yMapSize = int(myVizEngine.mapMatrix.sizeY) billboardList = 0 def getVizEngine(self): return self.myVizEngine def OnDraw(self): print "In Gallery.OnDraw" self.SetCurrent() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glCallList(self.billboardList) glFlush() self.SwapBuffers() def SetPosition(self, camX, camY, camZ, viewX, viewY, viewZ): """Sets the viewpoint at which to look Called when the user moves from one location to another""" print "In Gallery.SetPosition" self.SetCurrent() # Viewing transformation glLoadIdentity() gluLookAt(camX, camY, camZ, # camera position viewX, viewY, viewZ , # camera aimed at 0.0, 1.0, 0.0) # view-up matrix self.OnDraw() #self.SwapBuffers() def LookAt(self, x, z): """Positions the camera and viewpoint to look at the billboard at array position (x, z)""" print "Looking at position: ", x, z self.SetCurrent() billboardX = x * (self.distX + self.width) + self.width / 2 billboardY = 0.5 billboardZ = (z - 1) * self.distZ camX = billboardX camY = billboardY camZ = billboardZ - (self.distZ / 3) self.SetPosition(camX, camY, camZ, billboardX, billboardY, billboardZ) #self.OnDraw() #self.SwapBuffers() def DrawBillboard(self, x, y, z, filename, textureCount): self.textureId = self.LoadImage(filename, textureCount) self.SetupTexture(textureCount) glBindTexture(GL_TEXTURE_2D, self.vizImageIds[textureCount]) # Added 20061003 glBegin(GL_QUADS) leftX = x * (self.distX + self.width) rightX = leftX + self.width bottomY = y topY = y + self.height z = z * self.distZ glNormal3f(0.0, 0.0, -1.0) glTexCoord2f(0.0, 0.0); glVertex3f(leftX, bottomY, z) glTexCoord2f(1.0, 0.0); glVertex3f(rightX, bottomY, z) glTexCoord2f(1.0, 1.0); glVertex3f(rightX, topY, z) glTexCoord2f(0.0, 1.0); glVertex3f(leftX, topY, z) #glTexCoord2f(0.0, 0.0); glVertex3f(leftX, bottomY, z) #glTexCoord2f(0.0, 1.0); glVertex3f(leftX, topY, z) #glTexCoord2f(1.0, 1.0); glVertex3f(rightX, topY, z) #glTexCoord2f(1.0, 0.0); glVertex3f(rightX, bottomY, z) glEnd() def SetupTexture(self, textureId): glEnable(GL_TEXTURE_2D) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) #glBindTexture(GL_TEXTURE_2D, self.vizImageIds[textureId]) # Added 20061003 def LoadImage(self, filename, id): # First, load bitmap if filename == None: return None textureImageFile = None textureImageFile = open(filename, 'r') if textureImageFile: textureImageFile.close() im = Image.open(filename) try: ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1) except SystemError: ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1) glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) return self.vizImageIds[id] def CreateDisplayList(self): print "In Gallery.CreateDisplayList" self.billboardList = glGenLists(1) glNewList(self.billboardList, GL_COMPILE) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); # Draw a matrix of billboards #glBegin(GL_QUADS) textureCount = 0 for x in range(0, self.xMapSize): for z in range(0, self.yMapSize): textureFilename = self.myVizEngine.getViz([x, z]) y = 0 self.DrawBillboard(x, y, z, textureFilename, textureCount) textureCount += 1 #glEnd() self.LookAt(0, 0) #self.LookAt(0, 0) glEndList() def InitGL(self): print "In Gallery.InitGL" self.SetCurrent() glClearColor(0.7, 0.7, 0.7, 0.0) glShadeModel(GL_FLAT) glEnable(GL_DEPTH_TEST) glMatrixMode(GL_MODELVIEW) # Following commands affect model glLoadIdentity() self.vizImageIds = glGenTextures(self.xMapSize * self.yMapSize + 1) self.CreateDisplayList() #self.LookAt(0, 0) #self.OnDraw() #self.SwapBuffers() def FinishGL(self): pass class HistoryView(scrolled.ScrolledPanel): SPACING = 1 def __init__(self, parent, navigationWin): #wx.ScrolledWindow.__init__(self, parent, id=-1, pos=wx.DefaultPosition, # size=(700, 100), style=wx.HSCROLL, # name="History View") scrolled.ScrolledPanel.__init__(self, parent, -1, size=(840, 200)) #self.SetSize((700, 100)) #self.panel = wx.Panel(self, style=wx.BORDER_SUNKEN, size=(700, 100)) self.navigationWin = navigationWin self.history = navigationWin.history self.boxSizer = wx.BoxSizer(wx.HORIZONTAL) self.myVizEngine = vizGenerator.vizEngine.vizEngine(MAP_FILE_NAME, DATA_FILE_NAME) #self.OnDraw() #self.SetSizerAndFit(self.boxSizer) self.SetSizer(self.boxSizer) self.SetupScrolling(scroll_x=True) self.FitInside() # def OnDraw(self): # for x in range(0, self.history.getLength()): # currPos = self.history.getPosition(x) # textureFilename = myVizEngine.getViz([currPos.x, currPos.z]) # image = wx.Image(textureFilename, wx.BITMAP_TYPE_BMP) # width = image.GetWidth() # height = image.GetHeight() # print "Image Size: ", width, height # scaledImage = image.Scale(width * self.SCALE_FACTOR, height * self.SCALE_FACTOR) # #staticBitmap = wx.StaticBitmap(self.panel, -1, wx.BitmapFromImage(scaledImage)) # staticBitmap = wx.StaticBitmap(self, -1, wx.BitmapFromImage(scaledImage)) # self.boxSizer.Add(staticBitmap, 0, wx.ALL, self.SPACING) # # #self.Fit() # self.FitInside() def AddPosition(self, position): #currPos = self.history.getPosition(self.history.length - 1) #staticBitmap = wx.StaticBitmap(self, -1, wx.BitmapFromImage(scaledImage)) #staticBitmap = statbmp.GenStaticBitmap(self, wx.ID_ANY, scaledImage) historyButton = HistoryButton(self, position, self.myVizEngine) self.boxSizer.Add(historyButton, 0, wx.ALL, self.SPACING) self.FitInside() #size = self.GetVirtualSize() #self.Scroll(size[0], self.yPos) # def OnClick(self, event): #print "Image: was clicked at %i, %i " % (event.GetX(), event.GetY()) class HistoryButton(buttons.GenBitmapButton): SCALE_FACTOR = 0.5 def __init__(self, parent, position, vizEngine): self.position = position self.parent = parent textureFilename = vizEngine.getViz([position.x, position.z]) image = wx.Image(textureFilename, wx.BITMAP_TYPE_BMP) #image = wx.Bitmap(textureFilename) width = image.GetWidth() height = image.GetHeight() #print "Image Size: ", width, height scaledImage = image.Scale(width * self.SCALE_FACTOR, height * self.SCALE_FACTOR) bitmapImage = scaledImage.ConvertToBitmap() buttons.GenBitmapButton.__init__(self, parent, -1, bitmapImage, pos=(0, 0), style=0) self.Bind(wx.EVT_BUTTON, self.OnClick, self) def OnClick(self, event): self.parent.navigationWin.setPosition(self.position) #class HistoryView(myGLWindow): # textureImageIds = [] # # def __init__(self, parent, history): # self.history = history # myGLWindow.__init__(self, parent) # self.OnDraw() # # def OnDraw(self): # print "Drawing history view" # self.SetCurrent() # # clear color and depth buffers # glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); # # for x in range(0, self.history.getLength()): # currPos = self.history.getPosition(x) # textureFilename = myVizEngine.getViz([currPos.x, currPos.z]) # # self.textureId = self.LoadImage(textureFilename, x) # self.SetupTexture(x) # # leftX = 1.5 * x # rightX = 1.5 * x + 1 # bottomY = 0 # topY = 1 # z = 0 # # glBegin(GL_QUADS) # glTexCoord2f(0.0, 0.0); glVertex3f(leftX, bottomY, z) # glTexCoord2f(1.0, 0.0); glVertex3f(rightX, bottomY, z) # glTexCoord2f(1.0, 1.0); glVertex3f(rightX, topY, z) # glTexCoord2f(0.0, 1.0); glVertex3f(leftX, topY, z) # glEnd() # # glLoadIdentity() # gluLookAt(2.5, 0.5, 1.0, # camera position # 2.5, 0.5, 0.0, # camera aimed at # 0.0, 1.0, 0.0) # view-up matrix # # self.SwapBuffers() # # def InitGL(self): # #print "In InitGL for History View" # self.SetCurrent() # glClearColor(0.7, 0.7, 0.7, 0.0) # glShadeModel(GL_FLAT) # glEnable(GL_DEPTH_TEST) # # glMatrixMode(GL_MODELVIEW) # Following commands affect model # glLoadIdentity() # # self.textureImageIds = glGenTextures(MAX_HISTORY_SIZE) # self.SwapBuffers() # # def LoadImage(self, filename, id): # self.SetCurrent() # # First, load bitmap # if filename == None: # return None # textureImageFile = None # textureImageFile = open(filename, 'r') # if textureImageFile: # textureImageFile.close() # im = Image.open(filename) # try: # ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1) # except SystemError: # ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1) # # glPixelStorei(GL_UNPACK_ALIGNMENT, 1) # glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) # self.SwapBuffers() # return self.textureImageIds[id] # # def SetupTexture(self, textureId): # self.SetCurrent() # glEnable(GL_TEXTURE_2D) # glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) # glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) # glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) # glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) # # glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) # # glBindTexture(GL_TEXTURE_2D, self.textureImageIds[textureId]) # Added 20061003 # self.SwapBuffers() # class CurrentView(wx.Panel): def __init__(self, parent): self.position = [0, 0] wx.Panel.__init__(self, parent, style=wx.BORDER_SUNKEN, size=(60, 200)) box = wx.BoxSizer(wx.VERTICAL) self.widget = wxVTKRenderWindow(self, -1, pos=(100, 100), size=(170, 170)) myVizEngine = vizGenerator.vizEngine.vizEngine(MAP_FILE_NAME, DATA_FILE_NAME) ren = myVizEngine.getVtkViz(self.position) self.widget.GetRenderWindow().AddRenderer(ren) box.Add(self.widget, 0, wx.ALIGN_RIGHT) self.SetSizer(box) def SetPosition(self, position): self.position = position def OnDraw(self): self.widget = wxVTKRenderWindow(self, -1, pos=(100, 100), size=(170, 170)) myVizEngine = vizGenerator.vizEngine.vizEngine(MAP_FILE_NAME, DATA_FILE_NAME) ren = myVizEngine.getVtkViz(self.position) self.widget.GetRenderWindow().AddRenderer(ren) ============================================ |