0

I need help for PyOpenGL in pygame. I want to be able to rotate the view so it is global, I believe the term is. I want to be able to rotate left and right around the y (up) axis, and up and down toward the y axis.

How would I go about doing this?

The function used to rotate the view is:

glRotatef(angle, rotX, rotY, rotZ)

However, it only rotates around the axis.

Edit: Here's the code:

import pygame
from pygame.locals import *

from OpenGL.GL import *
from OpenGL.GLU import *

verticies = (
    (1, -1, -1),
    (1, 1, -1),
    (-1, 1, -1),
    (-1, -1, -1),
    (1, -1, 1),
    (1, 1, 1),
    (-1, -1, 1),
    (-1, 1, 1)
    )

edges = (
    (0,1),
    (0,3),
    (0,4),
    (2,1),
    (2,3),
    (2,7),
    (6,3),
    (6,4),
    (6,7),
    (5,1),
    (5,4),
    (5,7)
    )


def Cube():
    glBegin(GL_LINES)
    for edge in edges:
        for vertex in edge:
            glVertex3fv(verticies[vertex])
    glEnd()


def main():
    pygame.init()
    display = (800,600)
    pygame.display.set_mode(display, DOUBLEBUF|OPENGL)

    gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)

    glTranslatef(0.0,0.0, -5)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
            elif(event.type == pygame.K_LEFT):
                left() #?
            elif(event.type == pygame.K_RIGHT):
                right() #?
            # up.. down.. etc


        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        Cube()
        pygame.display.flip()
        pygame.time.wait(10)


main()
Jesus Cuevas
  • 57
  • 1
  • 6

0 Answers0