def shape_triangles_mat4_attribute(cfg): cfg.aspect_ratio = (1, 1) p0, p1, p2 = equilateral_triangle_coords(1) geometry = ngl.Triangle(p0, p1, p2) matrices = ngl.BufferMat4(data=array.array( "f", [ # fmt: off 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, 1.0, # fmt: on ], )) program = ngl.Program( vertex=TRIANGLES_MAT4_ATTRIBUTE_VERT, fragment=cfg.get_frag("color"), ) render = ngl.Render(geometry, program, nb_instances=2) render.update_instance_attributes(matrix=matrices) render.update_frag_resources(color=ngl.UniformVec3(value=COLORS.orange), opacity=ngl.UniformFloat(1)) return render
def shape_triangles_mat4_attribute(cfg): cfg.aspect_ratio = (1, 1) p0, p1, p2 = equilateral_triangle_coords(1) geometry = ngl.Triangle(p0, p1, p2) matrices = ngl.BufferMat4(data=array.array('f', [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, 1.0, ])) program = ngl.Program( vertex=TRIANGLES_MAT4_ATTRIBUTE_VERT, fragment=cfg.get_frag('color'), ) render = ngl.Render(geometry, program, nb_instances=2) render.update_instance_attributes(matrix=matrices) render.update_uniforms(color=ngl.UniformVec4(value=COLORS['orange'])) return render
animated_buffer_vec2=lambda data: ngl.AnimatedBufferVec2( keyframes=_get_anim_kf(ngl.AnimKeyFrameBuffer, data)), animated_buffer_vec3=lambda data: ngl.AnimatedBufferVec3( keyframes=_get_anim_kf(ngl.AnimKeyFrameBuffer, data)), animated_buffer_vec4=lambda data: ngl.AnimatedBufferVec4( keyframes=_get_anim_kf(ngl.AnimKeyFrameBuffer, data)), animated_quat_mat4=lambda data: ngl.AnimatedQuat( keyframes=_get_anim_kf(ngl.AnimKeyFrameQuat, data), as_mat4=True), animated_quat_vec4=lambda data: ngl.AnimatedQuat( keyframes=_get_anim_kf(ngl.AnimKeyFrameQuat, data), as_mat4=False), array_float=lambda data: ngl.BufferFloat(data=data), array_int=lambda data: ngl.BufferInt(data=data), array_ivec2=lambda data: ngl.BufferIVec2(data=data), array_ivec3=lambda data: ngl.BufferIVec3(data=data), array_ivec4=lambda data: ngl.BufferIVec4(data=data), array_mat4=lambda data: ngl.BufferMat4(data=data), array_vec2=lambda data: ngl.BufferVec2(data=data), array_vec3=lambda data: ngl.BufferVec3(data=data), array_vec4=lambda data: ngl.BufferVec4(data=data), single_bool=lambda data: ngl.UniformBool(data), single_float=lambda data: ngl.UniformFloat(data), single_int=lambda data: ngl.UniformInt(data), single_ivec2=lambda data: ngl.UniformIVec2(data), single_ivec3=lambda data: ngl.UniformIVec3(data), single_ivec4=lambda data: ngl.UniformIVec4(data), single_uint=lambda data: ngl.UniformUInt(data), single_uvec2=lambda data: ngl.UniformUIVec2(data), single_uvec3=lambda data: ngl.UniformUIVec3(data), single_uvec4=lambda data: ngl.UniformUIVec4(data), single_mat4=lambda data: ngl.UniformMat4(data), single_quat_mat4=lambda data: ngl.UniformQuat(data, as_mat4=True),