I'm building a simple game in python using OpenGL.
I built my logic through classes, the classes generate the information and pass it to OpenGL.
Unfortunatly, OpenGL is using callback and I don't know how to use my class methods with this process.
class Drawer(object):
level = 0
def main_draw():
...
glutInit()
glutTimerFunc(interval, update, 0)
glutDisplayFunc(self.draw) #<----- here's my trouble
glutIdleFunc(self.draw) #<----- here's my trouble
...
def draw():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
refresh2d_custom(width, height, field_width, field_height)
#TODO
draw_walls()
glutSwapBuffers()
I don't think a static method would work since my class would have multiple instances.
If I use functions directly, which seems the easiest solution so far, how would I pass an instance to a specific file?
#draw.py
#instance that has been pass to this file. It is not instanciated in draw.py
#level would be global in this file
level = MyGameInstance.level