-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab5-2-start.py
More file actions
40 lines (27 loc) · 992 Bytes
/
lab5-2-start.py
File metadata and controls
40 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from OpenGL.GL import *
from meshes import load
from app import run, readFile
from glslprogram import Program
from matrix import Matrix
from math import pi
vsCode = readFile('./shaders/lab5-2.vert')
fsCode = readFile('./shaders/lab5-2.frag')
def init():
global program
global displayCount
program = Program(vsCode, fsCode)
program.use()
displayCount = load(program.programId, "./models/monkey")
projection = Matrix.makePerspective()
invCameraPos = Matrix.makeTranslation(0, 0, -4)
mProjView = projection @ invCameraPos
program.setUniformMat4('mProjView', mProjView)
glEnable(GL_CULL_FACE)
glEnable(GL_DEPTH_TEST)
def update(dt, time):
speed = time * 0.7
program.setUniformMat4(
'mModel', Matrix.makeRotationY(pi+speed) @ Matrix.makeRotationX(pi/8))
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glDrawElements(GL_TRIANGLES, displayCount, GL_UNSIGNED_SHORT, None)
run("2DT904 - Illumination", init, update)