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


Python gloo.set_state方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def __init__(self, size, cam):

        app.Canvas.__init__(self, show=False, size=size)
        self.shape = (size[1], size[0])
        self.yz_flip = np.eye(4, dtype=np.float32)
        self.yz_flip[1, 1], self.yz_flip[2, 2] = -1, -1

        self.set_cam(cam)

        # Set up shader programs
        self.program_col = gloo.Program(_vertex_code_colored, _fragment_code_colored)
        self.program_tex = gloo.Program(_vertex_code_textured, _fragment_code_textured)

        # Texture where we render the color/depth and its FBO
        self.col_tex = gloo.Texture2D(shape=self.shape + (3,))
        self.fbo = gloo.FrameBuffer(self.col_tex, gloo.RenderBuffer(self.shape))
        self.fbo.activate()
        gloo.set_state(depth_test=True, blend=False, cull_face=True)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gloo.set_clear_color((0.0, 0.0, 0.0))
        gloo.set_viewport(0, 0, *self.size) 
開發者ID:kirumang,項目名稱:Pix2Pose,代碼行數:23,代碼來源:renderer.py

示例2: __init__

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def __init__(self):
        app.Canvas.__init__(self,
                            keys='interactive')

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.program['index'] = [(x,) for x in range(num_bins)] * num_lines
        self.program['line'] = [(x,) * num_bins for x in range(num_lines)]
        self.program['map_offset'] = 0

        self.program['num_bins'] = num_bins
        self.program['num_lines'] = num_lines

        heightmap = np.random.random(size=(num_lines, num_bins)).astype('float32')

        self.program['heightmap'] = gloo.Texture2D(data=heightmap, internalformat='r32f')
        #print (dir(self.program['heightmap']))

        self.program['colormap'] = Colormap(['r', 'g', 'b']).map(np.linspace(0, 1, 64)).astype('float32')

        gloo.set_viewport(0, 0, *self.physical_size)

        gloo.set_state(clear_color='black', blend=True,
                       blend_func=('src_alpha', 'one_minus_src_alpha'))

        self.show() 
開發者ID:strfry,項目名稱:OpenNFB,代碼行數:27,代碼來源:waterfall.py

示例3: disable_cull_face

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def disable_cull_face(self):        
        gloo.set_state(depth_test=True, blend=True, cull_face=False)   
        print("disabled cull_face") 
開發者ID:kirumang,項目名稱:Pix2Pose,代碼行數:5,代碼來源:renderer.py

示例4: draw_color

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def draw_color(self):
        program = gloo.Program(_color_vertex_code, _color_fragment_code)
        program.bind(self.vertex_buffer)
        program['u_light_eye_pos'] = [0, 0, 0]
        program['u_light_ambient_w'] = self.ambient_weight
        program['u_mv'] = _compute_model_view(self.mat_model, self.mat_view)
        # program['u_nm'] = compute_normal_matrix(self.model, self.view)
        program['u_mvp'] = _compute_model_view_proj(self.mat_model, self.mat_view, self.mat_proj)

        # Texture where we render the scene
        render_tex = gloo.Texture2D(shape=self.shape + (4,))

        # Frame buffer object
        fbo = gloo.FrameBuffer(render_tex, gloo.RenderBuffer(self.shape))
        with fbo:
            gloo.set_state(depth_test=True)
            gloo.set_state(cull_face=True)
            gloo.set_cull_face('back')  # Back-facing polygons will be culled
            gloo.set_clear_color(self.bg_color)
            gloo.clear(color=True, depth=True)
            gloo.set_viewport(0, 0, *self.size)
            program.draw('triangles', self.index_buffer)

            # Retrieve the contents of the FBO texture
            self.rgb = gloo.read_pixels((0, 0, self.size[0], self.size[1]))[:, :, :3]
            self.rgb = np.copy(self.rgb)

        fbo.delete()
        render_tex.delete()
        program.delete() 
開發者ID:meiqua,項目名稱:patch_linemod,代碼行數:32,代碼來源:renderer.py

示例5: draw_depth

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def draw_depth(self):
        program = gloo.Program(_depth_vertex_code, _depth_fragment_code)
        program.bind(self.vertex_buffer)
        program['u_mv'] = _compute_model_view(self.mat_model, self.mat_view)
        program['u_mvp'] = _compute_model_view_proj(self.mat_model, self.mat_view, self.mat_proj)

        # Texture where we render the scene
        render_tex = gloo.Texture2D(shape=self.shape + (4,), format=gl.GL_RGBA,
                                    internalformat=gl.GL_RGBA32F)

        # Frame buffer object
        fbo = gloo.FrameBuffer(render_tex, gloo.RenderBuffer(self.shape, format='depth'))
        with fbo:
            gloo.set_state(depth_test=True)
            gloo.set_state(cull_face=True)
            gloo.set_cull_face('back')  # Back-facing polygons will be culled
            gloo.set_clear_color((0.0, 0.0, 0.0, 0.0))
            gloo.clear(color=True, depth=True)
            gloo.set_viewport(0, 0, *self.size)
            program.draw('triangles', self.index_buffer)

            # Retrieve the contents of the FBO texture
            self.depth = self.read_fbo_color_rgba32f(fbo)
            self.depth = self.depth[:, :, 0] # Depth is saved in the first channel

        fbo.delete()
        render_tex.delete()
        program.delete() 
開發者ID:meiqua,項目名稱:patch_linemod,代碼行數:30,代碼來源:renderer.py

示例6: clear

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def clear(self, color=True, depth=True):
		"""Clear the renderer background."""
		gloo.set_state(clear_color=self.background_color)
		gloo.clear(color=color, depth=depth) 
開發者ID:p5py,項目名稱:p5,代碼行數:6,代碼來源:renderer2d.py

示例7: _comm_toggles

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def _comm_toggles(self, state=True):
		gloo.set_state(blend=state)
		gloo.set_state(depth_test=state)

		if state:
			gloo.set_state(blend_func=('src_alpha', 'one_minus_src_alpha'))
			gloo.set_state(depth_func='lequal') 
開發者ID:p5py,項目名稱:p5,代碼行數:9,代碼來源:renderer2d.py

示例8: __init__

# 需要導入模塊: from vispy import gloo [as 別名]
# 或者: from vispy.gloo import set_state [as 別名]
def __init__(self, size, cam):

        app.Canvas.__init__(self, show=False, size=size)
        self.shape = (size[1], size[0])
        self.yz_flip = np.eye(4, dtype=np.float32)
        self.yz_flip[1, 1], self.yz_flip[2, 2] = -1, -1

        self.set_cam(cam)

        # Set up shader programs
        self.program_col = gloo.Program(_vertex_code_colored, _fragment_code_colored)
        self.program_bbox = gloo.Program(_vertex_code_colored, _fragment_code_bbox)
        self.program_tex = gloo.Program(_vertex_code_textured, _fragment_code_textured)
        self.program_bg = gloo.Program(_vertex_code_background, _fragment_code_background)

        # Texture where we render the color/depth and its FBO
        self.col_tex = gloo.Texture2D(shape=self.shape + (3,))
        self.fbo = gloo.FrameBuffer(self.col_tex, gloo.RenderBuffer(self.shape))
        self.fbo.activate()
        gloo.set_state(depth_test=True, blend=False, cull_face=True)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gloo.set_clear_color((0.0, 0.0, 0.0))
        gloo.set_viewport(0, 0, *self.size)

        # Set up background render quad in NDC
        quad = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
        tex = [[0, 1], [1, 1], [1, 0], [0, 0]]
        vertices_type = [('a_position', np.float32, 2), ('a_texcoord', np.float32, 2)]
        collated = np.asarray(list(zip(quad, tex)), vertices_type)
        self.bg_vbuffer = gloo.VertexBuffer(collated)
        self.bg_ibuffer = gloo.IndexBuffer([0, 1, 2, 0, 2, 3]) 
開發者ID:fabi92,項目名稱:eccv18-rgb_pose_refinement,代碼行數:33,代碼來源:renderer.py


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