jonwright / pyopengltk

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

Move object with key input. #24

Closed ShaunKulesa closed 2 years ago

ShaunKulesa commented 3 years ago

So i have this buts its not doing anything.


    def initgl(self):

        GL.glLoadIdentity()
        GLU.gluPerspective(45, (self.width/self.height), 0.1, 50.0)
        GL.glTranslatef(0.0,0.0, -5)

    def redraw(self):
        pygame.init()
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    glTranslatef(-1.0,0,0.0)```
jonwright commented 3 years ago

Do you call init every time you do a redraw? For Tk you would need to bind keys to a widget,e.g. https://pythonprogramming.altervista.org/tkinter-key-binding/

ShaunKulesa commented 3 years ago

I dont know, i know redraw is every frame and initgl is at the start. This is off your cube example.

ShaunKulesa commented 3 years ago

Ahh i see where you are coming from, i was using pygame inputs and i wasn't even running a pygame window.