11import os
2+
23from pyrr import Matrix33
4+
35from demosys .conf import settings
46from demosys .resources import shaders
57
8+ from OpenGL import GL
9+
610settings .add_shader_dir (os .path .join (os .path .dirname (__file__ ), 'shaders' ))
711
812
@@ -51,10 +55,16 @@ def draw(self, mesh, proj_mat, view_mat):
5155
5256 mesh .vao .bind (self .shader )
5357
54- if mesh .material and mesh .material .color :
55- self .shader .uniform_4fv ("color" , mesh .material .color )
56- else :
57- self .shader .uniform_4fv ("color" , [1.0 , 1.0 , 1.0 , 1.0 ])
58+ if mesh .material :
59+ if mesh .material .double_sided :
60+ GL .glDisable (GL .GL_CULL_FACE )
61+ else :
62+ GL .glEnable (GL .GL_CULL_FACE )
63+
64+ if mesh .material .color :
65+ self .shader .uniform_4fv ("color" , mesh .material .color )
66+ else :
67+ self .shader .uniform_4fv ("color" , [1.0 , 1.0 , 1.0 , 1.0 ])
5868
5969 self .shader .uniform_mat4 ("m_proj" , proj_mat )
6070 self .shader .uniform_mat4 ("m_mv" , view_mat )
@@ -81,6 +91,11 @@ def __init__(self, shader=None, **kwargs):
8191 def draw (self , mesh , proj_mat , view_mat ):
8292 m_normal = self .create_normal_matrix (view_mat )
8393
94+ if mesh .material .double_sided :
95+ GL .glDisable (GL .GL_CULL_FACE )
96+ else :
97+ GL .glEnable (GL .GL_CULL_FACE )
98+
8499 mesh .vao .bind (self .shader )
85100 self .shader .uniform_sampler_2d (0 , "texture0" , mesh .material .mat_texture .texture ,
86101 sampler = mesh .material .mat_texture .sampler )
0 commit comments