-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab5-2-solution.py
More file actions
41 lines (27 loc) · 980 Bytes
/
lab5-2-solution.py
File metadata and controls
41 lines (27 loc) · 980 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
41
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-solution.vert')
fsCode = readFile('./shaders/lab5-2-solution.frag')
def init():
global program
global displayCount
program = Program(vsCode, fsCode)
program.use()
displayCount = load(program.programId, "./models/monkey")
program.setUniformMat4('mProj', Matrix.makePerspective())
glEnable(GL_CULL_FACE)
glEnable(GL_DEPTH_TEST)
def update(dt, time):
speed = time * 0.7
mView = Matrix.makeTranslation(0, 0, -4)
mModelView = mView @ Matrix.makeRotationY(
pi+speed) @ Matrix.makeRotationX(pi/8)
program.setUniformMat4(
'mModelView', mModelView)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glDrawElements(GL_TRIANGLES, displayCount, GL_UNSIGNED_SHORT, None)
run("2DT904 - Illumination", init, update)