Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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;
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;
}
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);
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
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
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
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);