How to use the moderngl.Uniform function in moderngl

To help you get started, we’ve selected a few moderngl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moderngl / moderngl / tests / test_uniform.py View on Github external
}
            ''',
        )

        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)
github moderngl / moderngl / tests / test_uniform_block_new.py View on Github external
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)
github moderngl / moderngl / tests / test_uniform.py View on Github external
}
                }
            ''',
        )

        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)
github moderngl / moderngl / tests / test_uniform_block_new.py View on Github external
''',
        )

        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)
github moderngl / moderngl / tests / test_program.py View on Github external
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)
github moderngl / moderngl / tests / test_program.py View on Github external
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)
github Contraz / demosys-py / demosys / opengl / shader.py View on Github external
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
            ))