DKL9 GitList
Repositories
DKL9 home
voxels
Code
Commits
Branches
Tags
Search
Tree:
dfcfe5f
Branches
Tags
master
voxels
ex.py
Correct voxel raycast, voxel types, reflectance
dkl9
commited
dfcfe5f
at 2025-175 11:55:45
ex.py
Blame
History
Raw
from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * import sys import time lf = time.time() fc = 0 def reshape(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(45, width / float(height or 1), 1, 50) glMatrixMode(GL_MODELVIEW) def draw_cube(): glutWireCube(1) def display(): global lf, fc glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() glTranslatef(0, 0, -5) glRotatef((60 * time.time()) % 360, 2, 1, 0) draw_cube() glutSwapBuffers() fc += 1 now = time.time() if now - lf >= 1.0: print(f"{fc} FPS") fc = 0 lf = now def keyboard(key, x, y): if key == b'\x1b': # ESC glutLeaveMainLoop() glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) glutInitWindowSize(500, 500) glutInitWindowPosition(100, 100) glutCreateWindow("PyOpenGL Cube") glEnable(GL_DEPTH_TEST) glutDisplayFunc(display) glutIdleFunc(display) glutReshapeFunc(reshape) glutKeyboardFunc(keyboard) glutMainLoop()