How to use the moderngl.next.create_context 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 / experimental / print_info.py View on Github external
import json

import moderngl.next as mgl

ctx = mgl.create_context(standalone=True, debug=True)

print('Limits:', json.dumps(ctx.limits.json(), indent=2))
print('Extensions:', json.dumps(mgl.extensions(ctx), indent=2))
print('Hardware Info:', json.dumps(mgl.hwinfo(ctx), indent=2))
print('Version Code:', ctx.version_code)
github moderngl / moderngl / examples / next / crate_render_batch.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()
        # import gltraces
        # mglprocs = mgl.glprocs(self.ctx)
        # gltraces.glprocs[:] = mglprocs
        # mglprocs[:] = gltraces.gltraces

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                uniform mat4 Mvp;

                in vec3 in_vert;
                in vec3 in_norm;
                in vec2 in_text;

                out vec3 v_vert;
github moderngl / moderngl / examples / next / multi_texture_terrain.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                uniform mat4 Mvp;
                uniform sampler2D Heightmap;

                in vec2 in_vert;
                out vec2 v_text;

                void main() {
                    vec4 vertex = vec4(in_vert - 0.5, texture(Heightmap, in_vert).r * 0.2, 1.0);
                    gl_Position = Mvp * vertex;
                    v_text = in_vert;
                }
github moderngl / moderngl / examples / next / 03_alpha_blending.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                in vec2 vert;

                in vec4 vert_color;
                out vec4 frag_color;

                uniform vec2 scale;
                uniform float rotation;

                void main() {
                    frag_color = vert_color;
                    float r = rotation * (0.5 + gl_InstanceID * 0.05);
github moderngl / moderngl / examples / next / mug_mockup.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.canvas_prog = self.ctx.program(
            vertex_shader='''
                #version 330

                in vec2 in_vert;
                out vec2 v_vert;

                void main() {
                    gl_Position = vec4(in_vert * 2.0 - 1.0, 0.0, 1.0);
                    v_vert = in_vert;
                }
            ''',
            fragment_shader='''
                #version 330
github moderngl / moderngl / examples / next / simple_grid.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                uniform mat4 Mvp;

                in vec3 in_vert;

                void main() {
                    gl_Position = Mvp * vec4(in_vert, 1.0);
                }
            ''',
            fragment_shader='''
                #version 330
github moderngl / moderngl / examples / next / julia_set.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                in vec2 in_vert;
                out vec2 v_text;

                void main() {
                    gl_Position = vec4(in_vert, 0.0, 1.0);
                    v_text = in_vert;
                }
            ''',
            fragment_shader='''
                #version 330
github moderngl / moderngl / examples / next / 02_uniforms_and_attributes.py View on Github external
def __init__(self):
        self.ctx = mgl.create_context()

        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330
                in vec2 vert;

                uniform vec2 scale;
                uniform float rotation;

                void main() {

                    mat2 rot = mat2(
                        cos(rotation), sin(rotation),
                        -sin(rotation), cos(rotation)
                    );
                    gl_Position = vec4((rot * vert) * scale, 0.0, 1.0);