本文整理汇总了Python中OpenGL.GL.glActiveTexture方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glActiveTexture方法的具体用法?Python GL.glActiveTexture怎么用?Python GL.glActiveTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glActiveTexture方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def render(self, pixmap, viewport_shape):
"""Renders the pixmap on a fullscreen quad.
Args:
pixmap: A 3D numpy array of bytes (np.uint8), with dimensions
(width, height, 3).
viewport_shape: A tuple of two elements, (width, height).
"""
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glViewport(0, 0, *viewport_shape)
GL.glUseProgram(self._shader)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, self._texture)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, pixmap.shape[1],
pixmap.shape[0], 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
pixmap)
GL.glUniform1i(self._var_texture_sampler, 0)
GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4)
示例2: display_gl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [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)
示例3: bindTextures
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def bindTextures(self, shader):
index = 0
for sampler, entry in self.textures.items():
shader.uniformi(sampler, index)
gl.glActiveTexture(gl.GL_TEXTURE0 + index)
gl.glBindTexture(gl.GL_TEXTURE_2D, entry.texture.textureId)
index += 1
示例4: unbindTextures
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def unbindTextures(self):
for i in range(len(self.textures)):
gl.glActiveTexture(gl.GL_TEXTURE0 + i)
gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
gl.glActiveTexture(gl.GL_TEXTURE0)
示例5: render
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def render(self, context):
self.shader.bind()
self.setUniforms(self.shader, context.uniforms)
self.shader.uniformf("screenSize", *self.getSize())
gl.glClearColor(*self.clearColor)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glDisable(gl.GL_DEPTH_TEST)
transforms = self.computeBoneTransforms()
boneMatrixArray = []
for i, transform in enumerate(transforms):
boneMatrix = transform.matrix
boneMatrix.p = transform.transparency #Abuse unused matrix location
overwrite = transform.damping > 0.0
if overwrite and self.oldFrameData.get(transform.bone.name):
overwrite = self.dampenBoneTransform(context, transform)
if overwrite:
self.oldFrameData[transform.bone.name] = SkinnedFrameData(context.shownTime, transform)
boneMatrixArray.extend(utils.matrixToList(boneMatrix))
self.shader.uniformMatrix4fArray("boneMatrices", boneMatrixArray)
for transform in transforms:
self.renderBoneTransform(transform, context)
for i in range(2):
gl.glActiveTexture(gl.GL_TEXTURE0 + i)
gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
gl.glActiveTexture(gl.GL_TEXTURE0)
self.shader.unbind()
示例6: _load
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def _load(self, surface):
self.free()
self.width = surface.get_width()
self.height = surface.get_height()
self.textureId = 0
textureId = (gl.GLuint * 1)()
surface.lock()
BYTEP = ctypes.POINTER(ctypes.c_ubyte)
ptr = ctypes.cast(surface._pixels_address, BYTEP)
gl.glGenTextures(1, textureId)
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glActiveTexture(gl.GL_TEXTURE0)
gl.glPixelStorei(gl.GL_UNPACK_ROW_LENGTH, surface.get_pitch() // surface.get_bytesize())
gl.glBindTexture(gl.GL_TEXTURE_2D, textureId[0])
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.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, self.width, self.height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, ptr)
gl.glBindTexture(gl.GL_TEXTURE_2D, 0);
gl.glPixelStorei(gl.GL_UNPACK_ROW_LENGTH, 0)
surface.unlock()
self.textureId = textureId[0]
示例7: bind
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def bind(self, index):
gl.glActiveTexture(gl.GL_TEXTURE0 + index)
gl.glBindTexture(gl.GL_TEXTURE_2D, self.textureId)
示例8: bind
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def bind(self, textureUnitId):
gl.glActiveTexture(gl.GL_TEXTURE0 + int(textureUnitId))
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, self.id_)
示例9: release
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def release(self, textureUnitId):
gl.glActiveTexture(gl.GL_TEXTURE0 + int(textureUnitId))
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, 0)
示例10: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def paintGL(self):
#GL.glClear(GL.GL_COLOR_BUFFER_BIT)
self.program.bind()
self.program.enableAttributeArray("position")
self.program.enableAttributeArray("texcoord")
self.program.setAttributeArray("position", self.quadCoord)
self.program.setAttributeArray("texcoord", self.quadCoordTex)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, self.texture)
self.program.setUniformValue("texture", 0)
GL.glDrawArrays(GL.GL_TRIANGLES, 0, len(self.quadCoord))
示例11: use
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def use(self):
gl.glActiveTexture(gl.GL_TEXTURE0 + 0)
gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.tex_id)
示例12: draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [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)
示例13: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glActiveTexture [as 别名]
def paintGL(self):
"""Paint the scene."""
# pass if the framebuffer isn't complete yet or if not initialized
if not (gl.glCheckFramebufferStatus(gl.GL_FRAMEBUFFER) == gl.GL_FRAMEBUFFER_COMPLETE and self.isVisible() and self.initialized):
return
gl.glClearColor(0, 0, 0, 0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
# Set the viewport and clear the framebuffer
# --- Draw the ND in its viewport ----
gl.glViewport(*self.ndviewport)
self.color_shader.use()
self.arcs.draw()
self.ownship.draw()
self.mask.draw()
self.edge.draw()
self.ticks.draw()
# Select the text shader
self.text_shader.use()
self.font.use()
self.font.set_block_size((0, 0))
self.globaldata.set_vertex_modifiers(VERTEX_IS_GLXY, True)
self.ticklbls.draw()
self.globaldata.set_vertex_modifiers(VERTEX_IS_GLXY, False)
self.spdlabel_text.draw()
self.spdlabel_val.draw()
# --- Draw the MCP in its viewport ---
gl.glViewport(*self.mcpviewport)
self.mcp_tex_shader.use()
gl.glActiveTexture(gl.GL_TEXTURE0 + 0)
gl.glBindTexture(gl.GL_TEXTURE_2D, self.mcp_texture)
self.mcp.draw()
gl.glBindTexture(gl.GL_TEXTURE_2D, self.btn_tex)
self.btn_leds.draw()
if self.updownpos is not None:
self.mcp_col_shader.use()
gl.glVertexAttrib2f(2, *self.updownpos)
self.updown.draw()
gl.glVertexAttrib2f(2, 0.0, 0.0)
self.mcp_txt_shader.use()
gl.glActiveTexture(gl.GL_TEXTURE0 + 0)
gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.lcd_tex)
self.mcp_text.draw()
# Unbind everything
RenderObject.unbind_all()
gl.glUseProgram(0)