Пример #1
0
def data_integer_iovars(cfg):
    cfg.aspect_ratio = (1, 1)
    vert = '''void main() {
    ngl_out_pos = ngl_projection_matrix * ngl_modelview_matrix * ngl_position;
    var_color_u32 = color_u32;
}
'''
    frag = '''void main() {
    ngl_out_color = vec4(var_color_u32) / 255.;
}'''
    program = ngl.Program(vertex=vert, fragment=frag)
    program.update_vert_out_vars(var_color_u32=ngl.IOIVec4())
    geometry = ngl.Quad(corner=(-1, -1, 0), width=(2, 0, 0), height=(0, 2, 0))
    render = ngl.Render(geometry, program)
    render.update_vert_resources(color_u32=ngl.UniformIVec4(value=(0x50, 0x80, 0xa0, 0xff)))
    return render
Пример #2
0
        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),
    single_quat_vec4=lambda data: ngl.UniformQuat(data, as_mat4=False),
    single_vec2=lambda data: ngl.UniformVec2(data),
    single_vec3=lambda data: ngl.UniformVec3(data),
    single_vec4=lambda data: ngl.UniformVec4(data),
)


def _get_field_decl(layout, f):
    t = f['type']