-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab3-4-solution.py
More file actions
38 lines (26 loc) · 916 Bytes
/
lab3-4-solution.py
File metadata and controls
38 lines (26 loc) · 916 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
from OpenGL.GL import *
import math
from app import run, readFile
from matrix import Matrix
from glslprogram import Program
from meshes import setupTriangle
vsCode = readFile('./shaders/lab3-4.vert')
fsCode = readFile('./shaders/lab3-3.frag')
def init():
global program
global drawCount
program = Program(vsCode, fsCode)
program.use()
drawCount = setupTriangle(program.programId)
projection = Matrix.makePerspective()
invCameraPos = Matrix.makeTranslation(0, 0, -255)
mProjView = projection @ invCameraPos
program.setUniformMat4('mProjView', mProjView)
def render(dt, time):
glClear(GL_COLOR_BUFFER_BIT)
mModel = Matrix.makeTranslation(
-200.0, 80.0, 0.0)
program.setUniformMat4('mModel', mModel)
program.setUniformFloat('time', time)
glDrawArraysInstanced(GL_TRIANGLES, 0, drawCount, 500*500)
run("2DT904 - Transformations", init, render)