May 2017
Beginner to intermediate
444 pages
11h 31m
English
The following code creates the 3D colored cube, which follows the code. This time, we will use the keyboard arrow keys to rotate the image instead of the mouse:
import pyglet from pyglet.gl import * from pyglet.window import key from OpenGL.GLUT import * WINDOW = 400 INCREMENT = 5 class Window(pyglet.window.Window): # Cube 3D start rotation xRotation = yRotation = 30 def __init__(self, width, height, title=''): super(Window, self).__init__(width, height, title) glClearColor(0, 0, 0, 1) glEnable(GL_DEPTH_TEST) def on_draw(self): # Clear the current GL Window self.clear() # Push Matrix onto stack glPushMatrix() glRotatef(self.xRotation, 1, 0, 0) glRotatef(self.yRotation, 0, 1, 0) # Draw the six sides of the cube ...
Read now
Unlock full access