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


Python GL.glUseProgram方法代碼示例

本文整理匯總了Python中OpenGL.GL.glUseProgram方法的典型用法代碼示例。如果您正苦於以下問題:Python GL.glUseProgram方法的具體用法?Python GL.glUseProgram怎麽用?Python GL.glUseProgram使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenGL.GL的用法示例。


在下文中一共展示了GL.glUseProgram方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: render

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [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: render_companion_window

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [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) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:25,代碼來源:hellovr_glfw.py

示例3: bind

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def bind(self):
        gl.glUseProgram(self.handle) 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:4,代碼來源:shaderprogram.py

示例4: unbind

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def unbind(self):
        gl.glUseProgram(0) 
開發者ID:bitsawer,項目名稱:renpy-shader,代碼行數:4,代碼來源:shaderprogram.py

示例5: bind

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def bind(self):
    if not self.is_linked:
      raise RuntimeError("Program must be linked before usage.")
    gl.glUseProgram(self.id_) 
開發者ID:PRBonn,項目名稱:semantic-kitti-api,代碼行數:6,代碼來源:glow.py

示例6: release

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def release(self):
    gl.glUseProgram(0) 
開發者ID:PRBonn,項目名稱:semantic-kitti-api,代碼行數:4,代碼來源:glow.py

示例7: use

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def use(self):
        gl.glUseProgram(self.program) 
開發者ID:TUDelft-CNS-ATM,項目名稱:bluesky,代碼行數:4,代碼來源:glhelpers.py

示例8: display_gl

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def display_gl(self, modelview, projection):
        self._check_devices()
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glUseProgram(self.shader)
        GL.glUniformMatrix4fv(0, 1, False, projection)
        for i in range(1, len(self.poses)):
            pose = self.poses[i]
            if not pose.bPoseIsValid:
                continue
            model_name = openvr.VRSystem().getStringTrackedDeviceProperty(i, openvr.Prop_RenderModelName_String)
            if model_name not in self.meshes:
                continue  # Come on, we already tried to load it a moment ago. Maybe next time.
            mesh = self.meshes[model_name]
            mesh.display_gl(modelview, projection, pose) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:16,代碼來源:tracked_devices_actor.py

示例9: render_scene

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [as 別名]
def render_scene(self, eye):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glEnable(GL.GL_DEPTH_TEST)
        if self.show_cubes:
            GL.glUseProgram(self.scene_program)
            GL.glUniformMatrix4fv(
                self.scene_matrix_location, 1, False,
                self.get_current_view_projection_matrix(eye))
            GL.glBindVertexArray(self.scene_vao)
            GL.glBindTexture(GL.GL_TEXTURE_2D, self.i_texture)
            GL.glDrawArrays(GL.GL_TRIANGLES, 0, int(self.vert_count))
            GL.glBindVertexArray(0)
        b_is_input_available = self.hmd.isInputAvailable()
        if b_is_input_available:
            # draw the controller axis lines
            GL.glUseProgram(self.controller_transform_program)
            GL.glUniformMatrix4fv(self.controller_matrix_location, 1, False, self.get_current_view_projection_matrix(eye))
            GL.glBindVertexArray(self.controller_vao)
            GL.glDrawArrays(GL.GL_LINES, 0, self.controller_vertex_count)
            GL.glBindVertexArray(0)
        # ----- Render Model rendering -----
        GL.glUseProgram(self.render_model_program)
        for hand in self.hand:
            if not hand.show_controller:
                continue
            if hand.render_model is None:
                continue
            mvp = hand.pose @ self.get_current_view_projection_matrix(eye)
            GL.glUniformMatrix4fv(self.render_model_matrix_location, 1, False, mvp)
            hand.render_model.draw()
        GL.glUseProgram(0) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:33,代碼來源:hellovr_glfw.py

示例10: paintGL

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glUseProgram [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.glUseProgram方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。