本文整理汇总了Python中OpenGL.GL.glDrawElements方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glDrawElements方法的具体用法?Python GL.glDrawElements怎么用?Python GL.glDrawElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glDrawElements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_gl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawElements [as 别名]
def display_gl(self, modelview, projection, pose):
if not self.model_is_loaded:
self._try_load_model()
return
if not self.texture_is_loaded:
self._try_load_texture()
return
controller_X_room = pose.mDeviceToAbsoluteTracking
controller_X_room = matrixForOpenVrMatrix(controller_X_room)
modelview0 = controller_X_room * modelview
# Repack before use, just in case
modelview0 = numpy.asarray(numpy.matrix(modelview0, dtype=numpy.float32))
GL.glUniformMatrix4fv(4, 1, False, modelview0)
normal_matrix = numpy.asarray(controller_X_room)
GL.glUniformMatrix4fv(8, 1, False, normal_matrix)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, self.diffuse_texture)
GL.glBindVertexArray(self.vao)
GL.glDrawElements(GL.GL_TRIANGLES, len(self.indexPositions), GL.GL_UNSIGNED_INT, None)
GL.glBindVertexArray(0)
示例2: render_companion_window
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawElements [as 别名]
def render_companion_window(self):
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, self.companion_width, self.companion_height)
GL.glBindVertexArray(self.companion_window_vao)
GL.glUseProgram(self.companion_window_program)
# render left eye (first half of index array)
i_size = sizeof(c_uint16)
count = int(self.companion_window_index_size / 2)
GL.glBindTexture(GL.GL_TEXTURE_2D, self.left_eye_desc.resolve_texture_id)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
GL.glDrawElements(GL.GL_TRIANGLES, count, GL.GL_UNSIGNED_SHORT, cast(0 * i_size, c_void_p))
# render right eye (second half of index array)
GL.glBindTexture(GL.GL_TEXTURE_2D, self.right_eye_desc.resolve_texture_id)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
GL.glDrawElements(GL.GL_TRIANGLES, count, GL.GL_UNSIGNED_SHORT, cast(count * i_size, c_void_p))
GL.glBindVertexArray(0)
GL.glUseProgram(0)
示例3: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawElements [as 别名]
def paintGL(self):
self.makeCurrent()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
self.program.bind()
self.program.enableAttributeArray("position")
self.vbo.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("position"), 2, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo)
self.program.enableAttributeArray("color")
self.vbo_cols.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("color"), 3, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo_cols)
self.vbo_index.bind()
#gl.glDrawArrays(gl.GL_TRIANGLES, 0, len(self.data))
gl.glDrawElements(gl.GL_TRIANGLES, len(self.index), gl.GL_UNSIGNED_INT, None)
print(self.context().format().majorVersion())
print(self.context().format().minorVersion())
print(gl.glGetString(gl.GL_VERSION));
示例4: draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawElements [as 别名]
def draw(self):
GL.glBindVertexArray(self.vertex_array)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, self.texture)
GL.glDrawElements(GL.GL_TRIANGLES, self.vertex_count, GL.GL_UNSIGNED_SHORT, None)
GL.glBindVertexArray(0)
示例5: renderBoneTransform
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawElements [as 别名]
def renderBoneTransform(self, transform, context):
bone = transform.bone
mesh = bone.mesh
if not bone.image or not mesh:
#No image or mesh attached
return
if not bone.visible or transform.transparency >= 1.0:
#Nothing to draw
return
tex = self.skinTextures.textures[bone.image.name]
texInfluence = self.skinTextures.textures.get(self.getInfluenceName(bone.image.name))
if not texInfluence:
texInfluence = self.skinTextures.textures[self.BLACK_TEXTURE]
self.shader.uniformi(shader.TEX0, 0)
tex.texture.bind(0)
self.shader.uniformi(shader.TEX1, 1)
texInfluence.texture.bind(1)
self.shader.uniformMatrix4f(shader.PROJECTION, self.getProjection())
self.bindAttributeArray(self.shader, "inVertex", mesh.vertices, 2)
self.bindAttributeArray(self.shader, "inUv", mesh.uvs, 2)
self.bindAttributeArray(self.shader, "inBoneWeights", mesh.boneWeights, 4)
self.bindAttributeArray(self.shader, "inBoneIndices", mesh.boneIndices, 4)
self.shader.uniformf("wireFrame", 0)
self.shader.uniformf("boneAlpha", max(1.0 - transform.transparency, 0))
gl.glDrawElements(gl.GL_TRIANGLES, len(mesh.indices), gl.GL_UNSIGNED_INT, mesh.indices)
if bone.wireFrame:
self.shader.uniformf("wireFrame", 1)
self.shader.uniformf("boneAlpha", 1.0)
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
gl.glDrawElements(gl.GL_TRIANGLES, len(mesh.indices), gl.GL_UNSIGNED_INT, mesh.indices)
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
self.unbindAttributeArray(self.shader, "inVertex")
self.unbindAttributeArray(self.shader, "inUv")
self.unbindAttributeArray(self.shader, "inBoneWeights")
self.unbindAttributeArray(self.shader, "inBoneIndices")