Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
''',
)
self.assertIn('in_vert', prog)
self.assertIn('Position', prog)
self.assertIn('Scale', prog)
self.assertIn('Mvp', prog)
self.assertIn('UseTexture', prog)
self.assertIn('Texture', prog)
self.assertIn('Color', prog)
self.assertIn('Alpha', prog)
self.assertIsInstance(prog['in_vert'], moderngl.Attribute)
self.assertIsInstance(prog['Position'], moderngl.Uniform)
self.assertIsInstance(prog['Scale'], moderngl.Uniform)
self.assertIsInstance(prog['Mvp'], moderngl.Uniform)
self.assertIsInstance(prog['UseTexture'], moderngl.Uniform)
self.assertIsInstance(prog['Texture'], moderngl.Uniform)
self.assertIsInstance(prog['Color'], moderngl.Uniform)
self.assertIsInstance(prog['Alpha'], moderngl.Uniform)
self.assertIn('in_vert', prog)
self.assertNotIn('Position', prog)
self.assertNotIn('Scale', prog)
self.assertIn('Mvp', prog)
self.assertIn('UseTexture', prog)
self.assertIn('Texture', prog)
self.assertNotIn('Color', prog)
self.assertNotIn('Alpha', prog)
self.assertIn('VertexShaderUniforms', prog)
self.assertIn('FragmentShaderUniforms', prog)
self.assertIsInstance(prog['in_vert'], moderngl.Attribute)
self.assertIsInstance(prog['Mvp'], moderngl.Uniform)
self.assertIsInstance(prog['UseTexture'], moderngl.Uniform)
self.assertIsInstance(prog['Texture'], moderngl.Uniform)
self.assertIsInstance(prog['VertexShaderUniforms'], moderngl.UniformBlock)
self.assertIsInstance(prog['FragmentShaderUniforms'], moderngl.UniformBlock)
}
}
''',
)
self.assertIn('in_vert', prog)
self.assertIn('Position', prog)
self.assertIn('Scale', prog)
self.assertIn('Mvp', prog)
self.assertIn('UseTexture', prog)
self.assertIn('Texture', prog)
self.assertIn('Color', prog)
self.assertIn('Alpha', prog)
self.assertIsInstance(prog['in_vert'], moderngl.Attribute)
self.assertIsInstance(prog['Position'], moderngl.Uniform)
self.assertIsInstance(prog['Scale'], moderngl.Uniform)
self.assertIsInstance(prog['Mvp'], moderngl.Uniform)
self.assertIsInstance(prog['UseTexture'], moderngl.Uniform)
self.assertIsInstance(prog['Texture'], moderngl.Uniform)
self.assertIsInstance(prog['Color'], moderngl.Uniform)
self.assertIsInstance(prog['Alpha'], moderngl.Uniform)
''',
)
self.assertIn('in_vert', prog)
self.assertNotIn('Position', prog)
self.assertNotIn('Scale', prog)
self.assertIn('Mvp', prog)
self.assertIn('UseTexture', prog)
self.assertIn('Texture', prog)
self.assertNotIn('Color', prog)
self.assertNotIn('Alpha', prog)
self.assertIn('VertexShaderUniforms', prog)
self.assertIn('FragmentShaderUniforms', prog)
self.assertIsInstance(prog['in_vert'], moderngl.Attribute)
self.assertIsInstance(prog['Mvp'], moderngl.Uniform)
self.assertIsInstance(prog['UseTexture'], moderngl.Uniform)
self.assertIsInstance(prog['Texture'], moderngl.Uniform)
self.assertIsInstance(prog['VertexShaderUniforms'], moderngl.UniformBlock)
self.assertIsInstance(prog['FragmentShaderUniforms'], moderngl.UniformBlock)
in vec2 v_vert;
out vec4 color;
void main() {
color = vec4(v_vert, 0.0, 1.0);
}
''',
)
self.assertIn('vert', program)
self.assertIn('pos', program)
self.assertIn('scale', program)
self.assertIsInstance(program['vert'], moderngl.Attribute)
self.assertIsInstance(program['pos'], moderngl.Uniform)
self.assertIsInstance(program['scale'], moderngl.Uniform)
in vec2 v_vert;
out vec4 color;
void main() {
color = vec4(v_vert, 0.0, 1.0);
}
''',
)
self.assertIn('vert', program)
self.assertIn('pos', program)
self.assertIn('scale', program)
self.assertIsInstance(program['vert'], moderngl.Attribute)
self.assertIsInstance(program['pos'], moderngl.Uniform)
self.assertIsInstance(program['scale'], moderngl.Uniform)
def _build_uniform_map(self):
"""
Builds an internal uniform map by querying the program.
This way we don't have to query OpenGL (can cause slowdowns)
"""
self.uniform_map = {k: v for k, v in self.program._members.items() if isinstance(v, moderngl.Uniform)}
print("ShaderProgram {} has {} uniform(s)".format(self.name, len(self.uniform_map)))
for _, uniform in self.uniform_map.items():
print(" - Uniform[{}] {} {} {}".format(
uniform.location, uniform.name, uniform.dimension, uniform.array_length
))