-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab4-1-start.py
More file actions
39 lines (27 loc) · 1010 Bytes
/
lab4-1-start.py
File metadata and controls
39 lines (27 loc) · 1010 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
from OpenGL.GL import *
from matrix import Matrix
from app import run, readFile
from glslprogram import Program
from meshes import setupCube
from math import pi
vsCode = readFile('./shaders/lab4-1.vert')
fsCode = readFile('./shaders/lab4-1.frag')
def init():
global drawCount
global program
program = Program(vsCode, fsCode)
program.use()
drawCount = setupCube(program.programId, 2)
projection = Matrix.makePerspective()
invCameraPos = Matrix.makeTranslation(0, 0, -5)
mProjView = projection @ invCameraPos
program.setUniformMat4('mModel', Matrix.makeIdentity())
program.setUniformMat4('mProjView', mProjView)
def update(dt, time):
glClear(GL_COLOR_BUFFER_BIT)
# Draw cube near
mModel = Matrix.makeRotationZ(
time*pi / 2.5) @ Matrix.makeRotationX(time*pi / 5.5) @ Matrix.makeRotationY(pi / 3.5)
program.setUniformMat4('mModel', mModel)
glDrawArrays(GL_TRIANGLES, 0, drawCount)
run("2DT904 - Hidden surface removal", init, update)