當前位置: 首頁>>代碼示例>>Python>>正文


Python GL.glActiveTexture方法代碼示例

本文整理匯總了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) 
開發者ID:deepmind,項目名稱:dm_control,代碼行數:21,代碼來源:fullscreen_quad.py

示例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) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:22,代碼來源:tracked_devices_actor.py

示例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 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:9,代碼來源:rendering.py

示例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) 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:7,代碼來源:rendering.py

示例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() 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:39,代碼來源:rendering.py

示例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] 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:33,代碼來源:texture.py

示例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) 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:5,代碼來源:texture.py

示例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_) 
開發者ID:PRBonn,項目名稱:semantic-kitti-api,代碼行數:5,代碼來源:glow.py

示例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) 
開發者ID:PRBonn,項目名稱:semantic-kitti-api,代碼行數:5,代碼來源:glow.py

示例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)) 
開發者ID:maweigert,項目名稱:spimagine,代碼行數:16,代碼來源:test_opengl.py

示例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) 
開發者ID:TUDelft-CNS-ATM,項目名稱:bluesky,代碼行數:5,代碼來源:glhelpers.py

示例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) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:8,代碼來源:hellovr_glfw.py

示例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) 
開發者ID:TUDelft-CNS-ATM,項目名稱:bluesky,代碼行數:58,代碼來源:blipdriver.py


注:本文中的OpenGL.GL.glActiveTexture方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。