-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtu_08_transparency.py
37 lines (28 loc) · 1.48 KB
/
tu_08_transparency.py
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
# import os,sys
# sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from OpenGL.GL import * # pylint: disable=W0614
from utils.meshViewer import MeshViewWindow, meshWithRender
from utils.shaderLoader import Shader
import glm
from utils.basicShading import basicShading
# no different with tutorial 07 , only changed shader
class AlphaShading(basicShading):
def loadShader(self):
self.shader = Shader()
self.shader.initShaderFromGLSL(
["glsl/tu08/StandardShading.vertexshader.glsl"], ["glsl/tu08/StandardTransparentShading.fragmentshader.glsl"])
self.MVP_ID = glGetUniformLocation(self.shader.program, "MVP")
self.ModelMatrix_ID = glGetUniformLocation(self.shader.program, "M")
self.ViewMatrix_ID = glGetUniformLocation(self.shader.program, "V")
self.Texture_ID = glGetUniformLocation(self.shader.program, "myTextureSampler")
self.Light_ID = glGetUniformLocation(self.shader.program, "LightPosition_worldspace")
self.OFFSET_ID = glGetUniformLocation(self.shader.program, "LOCATION_OFFSET")
class AlphaEnabledWin(MeshViewWindow):
def init_opengl(self):
MeshViewWindow.init_opengl(self)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
if __name__ == "__main__":
win = AlphaEnabledWin().init_default()
win.add_mesh(AlphaShading(meshName="resources/tu04/suzanne.obj",textureName="resources/tu04/uvmap.DDS"))
win.run()