jonwright / pyopengltk

OpenGL frame for Python/Tkinter via ctypes and pyopengl
MIT License
54 stars 13 forks source link

redraw not looping #28

Closed ShaunKulesa closed 3 years ago

ShaunKulesa commented 3 years ago

Hi Jon, so I'm launching a external game window from my scene editor and the redraw only prints "redraw" once which shows me its not looping. Any ideas on why its not? Here is the openglframe code:

class GameRender(OpenGLFrame):
    def initgl(self):
        print("initgl")
        GL.glViewport(0, 0, self.width, self.height)

        self.array = []
        with open("array.txt", "r") as read_array_txt:
            lines = read_array_txt.readlines()
            for line in lines:
                self.array.append(line)

        self.drawables = []
        for i in self.array:
            if i[1] == "Quad":
                if len(i) > 7:
                    self.texture = Texture(i[7])
                    self.drawables.append([i[0], Sprite(i[2], i[3], i[4], i[5], texture = self.texture)])
                else:
                    self.drawables.append([i[0], Sprite(i[2], i[3], i[4], i[5])])

    def redraw(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT)

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glOrtho(
            0,
            1920,
            1080,
            0,
            0, 1
        )

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity() 
        print("redraw")
        for obj in self.drawables:
            print(obj[1])
            a = obj[1]
            a.draw()
ShaunKulesa commented 3 years ago

ahhhhh i forgot game.animate = 1!