source: framspy/gui/visual/worldShader.py @ 1284

Last change on this file since 1284 was 1198, checked in by Maciej Komosinski, 22 months ago

Added simple Python GUI for Framsticks library/server

File size: 1.6 KB
Line 
1from gui.visual.shaderProgram import ShaderProgram
2import OpenGL.GL as gl
3import glm
4
5class 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")
Note: See TracBrowser for help on using the repository browser.