示例#1
0
def glShaderSource(shader, source):
    source_lines = source.splitlines()
    count = len(source_lines)
    strings = ffi.new('char*[]', count)
    lengths = ffi.new('int[]', count)
    ref_strings = []

    for i, line in enumerate(source_lines):
        cb = line.encode('ascii')
        s = ffi.new('char[]', cb)
        ref_strings.append(s)
        strings[i] = s
        lengths[i] = len(cb)

    lib.glShaderSource(shader, count, strings, lengths)
示例#2
0
def glGenBuffers(n):
    buffers = ffi.new('unsigned int[]', n)
    lib.glGenBuffers(n, buffers)
    return buffers
示例#3
0
def glGetUniformLocation(program, name):
    cname = ffi.new('char*', name)
    return lib.glGetUniformLocation(program, cname)
示例#4
0
def glGetAttribLocation(program, name):
    cname = ffi.new('char[]', name.encode('ascii'))
    return lib.glGetAttribLocation(program, cname)
示例#5
0
def glGetProgramInfoLog(program):
    max_length = 1024
    length = ffi.new('int*')
    infolog = ffi.new('char[]', max_length)
    lib.glGetProgramInfoLog(program, max_length, length, infolog)
    return infolog
示例#6
0
def glGetProgramiv(program, pname):
    params = ffi.new('int*')
    lib.glGetProgramiv(program, pname, params)
    return params[0]
示例#7
0
def glGetShaderInfoLog(shader):
    max_length = 2048
    length = ffi.new('int*')
    infolog = ffi.new('char[]', max_length)
    lib.glGetShaderInfoLog(shader, max_length, length, infolog)
    return ffi.string(infolog).decode('utf-8')
示例#8
0
def glGetShaderiv(shader, pname):
    params = ffi.new('int*')
    lib.glGetShaderiv(shader, pname, params)
    return params[0]