当前位置: 首页>>代码示例>>Python>>正文


Python GL.glBindBuffer方法代码示例

本文整理汇总了Python中OpenGL.GL.glBindBuffer方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glBindBuffer方法的具体用法?Python GL.glBindBuffer怎么用?Python GL.glBindBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenGL.GL的用法示例。


在下文中一共展示了GL.glBindBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_buffer

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def update_buffer(buf_id, data, offset=0, target=gl.GL_ARRAY_BUFFER):

    global msg1282

    try:
        gl.glBindBuffer(target, buf_id)
        gl.glBufferSubData(target, offset, data.nbytes, data)

    except Exception as err:
        if err.err==1282:
            if not msg1282:
                print("update_buffer: Communication aborted (1282)")
            msg1282 = True
        else:
            print("update_buffer in glhelpers.py: Could not update buffer due to GLError code:",\
                  err.err) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:18,代码来源:glhelpers.py

示例2: assign

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def assign(self, array):
    gl.glBindBuffer(self.target_, self.id_)
    gl.glBufferData(self.target_, array, self.usage_)
    gl.glBindBuffer(self.target_, 0) 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:6,代码来源:glow.py

示例3: bind

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def bind(self):
    gl.glBindBuffer(self.target_, self.id_) 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:4,代码来源:glow.py

示例4: release

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def release(self):
    gl.glBindBuffer(self.target_, 0) 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:4,代码来源:glow.py

示例5: create_empty_buffer

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def create_empty_buffer(size, target=gl.GL_ARRAY_BUFFER, usage=gl.GL_STATIC_DRAW):
    buf_id = gl.glGenBuffers(1)
    gl.glBindBuffer(target, buf_id)
    gl.glBufferData(target, size, None, usage)
    return buf_id 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:7,代码来源:glhelpers.py

示例6: __init__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def __init__(self, data):
        self.data = data
        self.nbytes = sizeof(data)
        self.ubo = gl.glGenBuffers(1)
        self.binding = self.max_binding
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, self.ubo)
        gl.glBufferData(gl.GL_UNIFORM_BUFFER, self.nbytes, pointer(self.data), gl.GL_STREAM_DRAW)
        gl.glBindBufferBase(gl.GL_UNIFORM_BUFFER, self.binding, self.ubo)
        UniformBuffer.max_binding += 1 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:11,代码来源:glhelpers.py

示例7: update

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def update(self, offset=0, size=None):
        if size is None:
            size = self.nbytes
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, self.ubo)
        gl.glBufferSubData(gl.GL_UNIFORM_BUFFER, offset, size, pointer(self.data)) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:7,代码来源:glhelpers.py

示例8: bind_attrib

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def bind_attrib(self, attrib_id, size, data, storagetype=gl.GL_STATIC_DRAW, instance_divisor=0, datatype=gl.GL_FLOAT, stride=0, offset=None, normalize=False):
        if RenderObject.bound_vao is not self.vao_id:
            gl.glBindVertexArray(self.vao_id)
            RenderObject.bound_vao = self.vao_id

        # Keep track of max instance divisor
        self.max_instance_divisor = max(instance_divisor, self.max_instance_divisor)

        # If the input is an array create a new GL buffer, otherwise assume the buffer already exists and a buffer ID is passed
        if type(data) is np.ndarray:
            # Get an index to one new buffer in GPU mem, bind it, and copy the array data to it
            buf_id = gl.glGenBuffers(1)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, buf_id)
            gl.glBufferData(gl.GL_ARRAY_BUFFER, data.nbytes, data, storagetype)
        else:
            # Assume that a GLuint is passed which means that the buffer is already in GPU memory
            buf_id = data
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, buf_id)

        # Assign this buffer to one of the attributes in the shader
        gl.glEnableVertexAttribArray(attrib_id)
        gl.glVertexAttribPointer(attrib_id, size, datatype, normalize, stride, offset)
        # For instanced data, indicate per how many instances we move a step in the buffer (1=per instance)
        if instance_divisor > 0:
            gl.glVertexAttribDivisor(attrib_id, instance_divisor)
        # Clean up
        gl.glDisableVertexAttribArray(attrib_id)

        self.enabled_attributes[attrib_id] = [size, buf_id, instance_divisor, datatype]

        return buf_id 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:33,代码来源:glhelpers.py

示例9: update_buffer

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def update_buffer(buf_id, data, offset=0, target=gl.GL_ARRAY_BUFFER):
    gl.glBindBuffer(target, buf_id)
    gl.glBufferSubData(target, offset, data.nbytes, data) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:5,代码来源:glhelpers.py

示例10: __init__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def __init__(self, data):
        if isinstance(data, np.ndarray):
            self.pdata  = data
            self.nbytes = data.nbytes
        else:
            self.pdata  = pointer(data)
            self.nbytes = sizeof(data)
        self.ubo = gl.glGenBuffers(1)
        self.binding = self.max_binding
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, self.ubo)
        gl.glBufferData(gl.GL_UNIFORM_BUFFER, self.nbytes, self.pdata, gl.GL_STREAM_DRAW)
        gl.glBindBufferBase(gl.GL_UNIFORM_BUFFER, self.binding, self.ubo)
        UniformBuffer.max_binding += 1 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:15,代码来源:glhelpers.py

示例11: update

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def update(self, offset=0, size=None):
        if size is None:
            size = self.nbytes
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, self.ubo)
        gl.glBufferSubData(gl.GL_UNIFORM_BUFFER, offset, size, self.pdata) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:7,代码来源:glhelpers.py

示例12: _init_geometry

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def _init_geometry(self):
    """Initializes the fullscreen quad geometry."""
    vertex_buffer = GL.glGenBuffers(1)
    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, vertex_buffer)
    GL.glBufferData(
        GL.GL_ARRAY_BUFFER,
        _FULLSCREEN_QUAD_VERTEX_POSITONS_AND_TEXTURE_COORDS.nbytes,
        _FULLSCREEN_QUAD_VERTEX_POSITONS_AND_TEXTURE_COORDS, GL.GL_STATIC_DRAW) 
开发者ID:deepmind,项目名称:dm_control,代码行数:10,代码来源:fullscreen_quad.py

示例13: set_up_scene

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def set_up_scene(self):
        self.vertex_data = []
        v = self.scene_volume_init
        s = self.scale_spacing
        scale = 0.3
        mat_scale = numpy.diag(numpy.array([scale, scale, scale, 1], dtype=numpy.float32))
        t = -0.5 * v * s
        mat_translate = translate(t, t, t)
        mat = mat_translate @ mat_scale
        for z in range(v):
            for y in range(v):
                for x in range(v):
                    self.add_cube_to_scene(mat)
                    mat = translate(s, 0, 0) @ mat
                mat = translate(-v * s, s, 0) @ mat
            mat = translate(0, -v * s, s) @ mat
        vertex_data = numpy.array(self.vertex_data, dtype=numpy.float32).flatten()
        self.vert_count = len(vertex_data) / 5
        self.scene_vao = GL.glGenVertexArrays(1)
        GL.glBindVertexArray(self.scene_vao)
        self.scene_vert_buffer = GL.glGenBuffers(1)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.scene_vert_buffer)
        GL.glBufferData(GL.GL_ARRAY_BUFFER, vertex_data, GL.GL_STATIC_DRAW)
        f_size = sizeof(c_float)
        stride = 5 * f_size
        GL.glEnableVertexAttribArray(0)
        GL.glVertexAttribPointer(0, 3, GL.GL_FLOAT, False, stride, cast(0 * f_size, c_void_p))
        GL.glEnableVertexAttribArray(1)
        GL.glVertexAttribPointer(1, 2, GL.GL_FLOAT, False, stride, cast(3 * f_size, c_void_p))
        GL.glBindVertexArray(0)
        GL.glDisableVertexAttribArray(0)
        GL.glDisableVertexAttribArray(1) 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:34,代码来源:hellovr_glfw.py

示例14: set_up_companion_window

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def set_up_companion_window(self):
        if not self.hmd:
            return
        verts = list()
        # left eye verts
        verts.append(((-1, -1), (0, 0)))
        verts.append(((0, -1), (1, 0)))
        verts.append(((-1, 1), (0, 1)))
        verts.append(((0, 1), (1, 1)))
        # right eye verts
        verts.append(((0, -1), (0, 0)))
        verts.append(((1, -1), (1, 0)))
        verts.append(((0, 1), (0, 1)))
        verts.append(((1, 1), (1, 1)))
        vIndices = numpy.array([0, 1, 3, 0, 3, 2, 4, 5, 7, 4, 7, 6], dtype=numpy.uint16)
        self.companion_window_index_size = len(vIndices)
        self.companion_window_vao = GL.glGenVertexArrays(1)
        GL.glBindVertexArray(self.companion_window_vao)
        #
        self.companion_window_id_vert_buffer = GL.glGenBuffers(1)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.companion_window_id_vert_buffer)
        vVerts = numpy.array(verts, dtype=numpy.float32).flatten()
        GL.glBufferData(GL.GL_ARRAY_BUFFER, vVerts, GL.GL_STATIC_DRAW)
        #
        self.companion_window_id_index_buffer = GL.glGenBuffers(1)
        GL.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, self.companion_window_id_index_buffer)
        GL.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, vIndices, GL.GL_STATIC_DRAW)
        #
        f_size = sizeof(c_float)
        GL.glEnableVertexAttribArray(0)
        GL.glVertexAttribPointer(0, 2, GL.GL_FLOAT, False, 4 * f_size, cast(0 * f_size, c_void_p))
        #
        GL.glEnableVertexAttribArray(1)
        GL.glVertexAttribPointer(1, 2, GL.GL_FLOAT, False, 4 * f_size, cast(2 * f_size, c_void_p))
        #
        GL.glBindVertexArray(0)
        GL.glDisableVertexAttribArray(0)
        GL.glDisableVertexAttribArray(1)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, 0)
        GL.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0) 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:42,代码来源:hellovr_glfw.py

示例15: _create_device_objects

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glBindBuffer [as 别名]
def _create_device_objects(self):
        # save state
        last_texture = gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D)
        last_array_buffer = gl.glGetIntegerv(gl.GL_ARRAY_BUFFER_BINDING)

        last_vertex_array = gl.glGetIntegerv(gl.GL_VERTEX_ARRAY_BINDING)

        self._shader_handle = gl.glCreateProgram()
        # note: no need to store shader parts handles after linking
        vertex_shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)

        gl.glShaderSource(vertex_shader, self.VERTEX_SHADER_SRC)
        gl.glShaderSource(fragment_shader, self.FRAGMENT_SHADER_SRC)
        gl.glCompileShader(vertex_shader)
        gl.glCompileShader(fragment_shader)

        gl.glAttachShader(self._shader_handle, vertex_shader)
        gl.glAttachShader(self._shader_handle, fragment_shader)

        gl.glLinkProgram(self._shader_handle)

        # note: after linking shaders can be removed
        gl.glDeleteShader(vertex_shader)
        gl.glDeleteShader(fragment_shader)

        self._attrib_location_tex = gl.glGetUniformLocation(self._shader_handle, "Texture")
        self._attrib_proj_mtx = gl.glGetUniformLocation(self._shader_handle, "ProjMtx")
        self._attrib_location_position = gl.glGetAttribLocation(self._shader_handle, "Position")
        self._attrib_location_uv = gl.glGetAttribLocation(self._shader_handle, "UV")
        self._attrib_location_color = gl.glGetAttribLocation(self._shader_handle, "Color")

        self._vbo_handle = gl.glGenBuffers(1)
        self._elements_handle = gl.glGenBuffers(1)

        self._vao_handle = gl.glGenVertexArrays(1)
        gl.glBindVertexArray(self._vao_handle)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._vbo_handle)

        gl.glEnableVertexAttribArray(self._attrib_location_position)
        gl.glEnableVertexAttribArray(self._attrib_location_uv)
        gl.glEnableVertexAttribArray(self._attrib_location_color)

        gl.glVertexAttribPointer(self._attrib_location_position, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_POS_OFFSET))
        gl.glVertexAttribPointer(self._attrib_location_uv, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_UV_OFFSET))
        gl.glVertexAttribPointer(self._attrib_location_color, 4, gl.GL_UNSIGNED_BYTE, gl.GL_TRUE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_COL_OFFSET))

        # restore state
        gl.glBindTexture(gl.GL_TEXTURE_2D, last_texture)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, last_array_buffer)
        gl.glBindVertexArray(last_vertex_array) 
开发者ID:swistakm,项目名称:pyimgui,代码行数:53,代码来源:opengl.py


注:本文中的OpenGL.GL.glBindBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。