renderer.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:hienoi 作者: christophercrouzet 项目源码 文件源码
def _set_vertex_attributes(vertex_format, layout, vbo_vertex_capacity):
    """Set the OpenGL vertex attributes."""
    gl.glBindVertexArray(vertex_format.vao)
    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, vertex_format.vbo)

    if layout == VertexLayout.INTERLEAVED:
        stride = sum(attr.size for attr in vertex_format.attributes)
        offsets = [0] + list(_accumulate([
            attr.size for attr in vertex_format.attributes[:-1]]))
    elif layout == VertexLayout.PACKED:
        stride = 0
        offsets = [0] + list(_accumulate([
            attr.size * vbo_vertex_capacity
            for attr in vertex_format.attributes[:-1]]))

    for i, attr in enumerate(vertex_format.attributes):
        gl.glEnableVertexAttribArray(attr.location)
        gl.glVertexAttribPointer(
            attr.location, attr.count, attr.type,
            attr.normalized, stride, ctypes.c_voidp(offsets[i]))
        gl.glVertexAttribDivisor(attr.location, attr.divisor)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号