Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.prog['scale'] = (height / width * 0.75, 0.75)
vertices = np.array([
1.0, 0.0,
1.0, 0.0, 0.0, 0.5,
-0.5, 0.86,
0.0, 1.0, 0.0, 0.5,
-0.5, -0.86,
0.0, 0.0, 1.0, 0.5,
])
self.vbo = self.ctx.buffer(vertices.astype('f4').tobytes())
self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'vert', 'vert_color')
self.blend = self.ctx.scope(enable_only=mgl.BLEND)
def __init__(self):
self.ctx = mgl.create_context()
self.prog = self.ctx.program(
vertex_shader='''
#version 330
in vec3 vert;
uniform float z_near;
uniform float z_far;
uniform float fovy;
uniform float ratio;
uniform vec3 center;
uniform vec3 eye;
uniform vec3 up;
def __init__(self, **kwargs):
super().__init__(**kwargs)
# self.sampler.filter = (mgl.LINEAR, mgl.LINEAR)
self.sampler.filter = mgl.LINEAR
self.sampler.wrap = mgl.REPEAT_X | mgl.REPEAT_Y
img5 = Image.new('RGB', (200, 200), '#fef')
img6 = Image.new('RGB', (200, 200), '#eff')
ImageDraw.ImageDraw(img1).text((50, 30), 'i1', '#000', ImageFont.truetype('arial', 128))
ImageDraw.ImageDraw(img2).text((50, 30), 'i2', '#000', ImageFont.truetype('arial', 128))
ImageDraw.ImageDraw(img3).text((50, 30), 'i3', '#000', ImageFont.truetype('arial', 128))
ImageDraw.ImageDraw(img4).text((50, 30), 'i4', '#000', ImageFont.truetype('arial', 128))
ImageDraw.ImageDraw(img5).text((50, 30), 'i5', '#000', ImageFont.truetype('arial', 128))
ImageDraw.ImageDraw(img6).text((50, 30), 'i6', '#000', ImageFont.truetype('arial', 128))
def join(*images):
return b''.join(img.tobytes('raw', 'RGB', 0, -1) for img in images)
self.texture = self.ctx.texture_cube((200, 200), 3, join(img1, img2, img3, img4, img5, img6))
self.sampler = self.ctx.sampler(self.texture)
self.sampler.filter = mgl.LINEAR
self.sampler.use()
obj = Obj.open(data.find('sitting_dummy.obj'))
self.vbo = self.ctx.buffer(obj.pack('vx vy vz nx ny nz'))
self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'in_vert', 'in_norm')
self.scope = self.ctx.scope(mgl.DEPTH_TEST)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.sampler.wrap = mgl.REPEAT_X | mgl.MIRROR_CLAMP_TO_EDGE_Y
def __init__(self):
self.ctx = mgl.create_context()
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;
out vec3 v_norm;
out vec2 v_text;
void main() {
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.ctx = mgl.create_context()
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;
out vec3 v_norm;
out vec2 v_text;
void main() {