1 | from gui.visual.shaderProgram import ShaderProgram
|
---|
2 | import OpenGL.GL as gl
|
---|
3 | import glm
|
---|
4 |
|
---|
5 | class WorldShader(ShaderProgram):
|
---|
6 | def __init__(self) -> None:
|
---|
7 | super().__init__("visual/shaders/WorldVertexShader.glsl", "visual/shaders/WorldFragmentShader.glsl", "visual/shaders/WorldGeometryShader.glsl")
|
---|
8 | self.bindAttributes()
|
---|
9 | gl.glLinkProgram(self.programID)
|
---|
10 | gl.glValidateProgram(self.programID)
|
---|
11 | self.getAllUniformLocations()
|
---|
12 |
|
---|
13 | def loadProjectionMatrix(self, matrix):
|
---|
14 | self.loadMatrix4(self.location_projectionMatrix, matrix)
|
---|
15 |
|
---|
16 | def loadViewMatrix(self, camera):
|
---|
17 | viewMatrix = glm.lookAt(camera.position, camera.player.position, glm.vec3(0, 0, 1))
|
---|
18 | self.loadMatrix4(self.location_viewMatrix, viewMatrix)
|
---|
19 |
|
---|
20 | def loadMode(self, mode: int):
|
---|
21 | self.loadInt(self.location_mode, mode)
|
---|
22 |
|
---|
23 | def loadWorldSize(self, size: float):
|
---|
24 | self.loadFloat(self.location_worldSize, size)
|
---|
25 |
|
---|
26 | def loadWaterLevel(self, level: float):
|
---|
27 | self.loadFloat(self.location_waterLevel, level)
|
---|
28 |
|
---|
29 | def bindAttributes(self):
|
---|
30 | self.bindAttribute(0, "position")
|
---|
31 | self.bindAttribute(1, "color")
|
---|
32 |
|
---|
33 | def getAllUniformLocations(self):
|
---|
34 | self.location_projectionMatrix = self.getUniformLocation("projectionMatrix")
|
---|
35 | self.location_viewMatrix = self.getUniformLocation("viewMatrix")
|
---|
36 | self.location_mode = self.getUniformLocation("mode")
|
---|
37 | self.location_worldSize = self.getUniformLocation("worldSize")
|
---|
38 | self.location_waterLevel = self.getUniformLocation("waterLevel") |
---|