Python vispy.gloo.clear() Examples
The following are 20
code examples of vispy.gloo.clear().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vispy.gloo
, or try the search function
.
Example #1
Source File: renderer.py From Pix2Pose with MIT License | 5 votes |
def render_view_metrical_clip(self, model, pose, diameter): cut = self.compute_metrical_clip(pose, diameter) self.clear() self.draw_model(model, pose) col, dep = self.finish() return col[cut[0]:cut[2], cut[1]:cut[3]], dep[cut[0]:cut[2], cut[1]:cut[3]]
Example #2
Source File: renderer.py From eccv18-rgb_pose_refinement with MIT License | 5 votes |
def render_view_metrical_clip(self, model, pose, diameter): cut = self.compute_metrical_clip(pose, diameter) self.clear() self.draw_model(model, pose) col, dep = self.finish() return col[cut[0]:cut[2], cut[1]:cut[3]], dep[cut[0]:cut[2], cut[1]:cut[3]]
Example #3
Source File: renderer.py From eccv18-rgb_pose_refinement with MIT License | 5 votes |
def draw_coordinate_system(self, model, pose): self.clear(color=False) # View matrix (transforming the coordinate system from OpenCV to OpenGL camera space) mv = (self.yz_flip.dot(pose)).T # OpenCV to OpenGL camera system (flipped, column-wise) mvp = mv.dot(self.mat_proj) self.program_bbox.bind(model.cs_vbuffer) self.program_bbox['u_mv'] = mv self.program_bbox['u_mvp'] = mvp gloo.set_line_width(width=3.0) self.program_bbox.draw('lines', model.cs_ibuffer) gloo.set_line_width(width=1.0)
Example #4
Source File: renderer.py From eccv18-rgb_pose_refinement with MIT License | 5 votes |
def draw_background(self, image): self.program_bg['u_tex'] = gloo.Texture2D(image) self.program_bg.bind(self.bg_vbuffer) self.program_bg.draw('triangles', self.bg_ibuffer) gloo.clear(color=False, depth=True) # Clear depth
Example #5
Source File: renderer.py From eccv18-rgb_pose_refinement with MIT License | 5 votes |
def clear(self, color=True, depth=True): gloo.clear(color=color, depth=True)
Example #6
Source File: waterfall.py From OpenNFB with GNU General Public License v3.0 | 5 votes |
def on_draw(self, event): gloo.clear() #self.program['a_position'] = #for line in range(num_lines): # self.program['line'] = line self.program.draw('line_strip')
Example #7
Source File: renderer3d.py From p5 with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: renderer3d.py From p5 with GNU General Public License v3.0 | 5 votes |
def reset_view(self): self.viewport = ( 0, 0, int(builtins.width * builtins.pixel_x_density), int(builtins.height * builtins.pixel_y_density), ) self.texture_viewport = ( 0, 0, builtins.width, builtins.height, ) gloo.set_viewport(*self.viewport) cz = (builtins.height / 2) / math.tan(math.radians(30)) self.projection_matrix = matrix.perspective_matrix( math.radians(60), builtins.width / builtins.height, 0.1 * cz, 10 * cz ) self.transform_matrix = np.identity(4) self.default_prog['projection'] = self.projection_matrix.T.flatten() self.default_prog['perspective_matrix'] = self.lookat_matrix.T.flatten() self.fbuffer_tex_front = Texture2D((builtins.height, builtins.width, 3)) self.fbuffer_tex_back = Texture2D((builtins.height, builtins.width, 3)) for buf in [self.fbuffer_tex_front, self.fbuffer_tex_back]: self.fbuffer.color_buffer = buf with self.fbuffer: self.clear() self.fbuffer.depth_buffer = gloo.RenderBuffer((builtins.height, builtins.width))
Example #9
Source File: renderer2d.py From p5 with GNU General Public License v3.0 | 5 votes |
def draw_loop(self): """The main draw loop context manager. """ self.transform_matrix = np.identity(4) self.default_prog['modelview'] = self.modelview_matrix.T.flatten() self.default_prog['projection'] = self.projection_matrix.T.flatten() self.fbuffer.color_buffer = self.fbuffer_tex_back with self.fbuffer: gloo.set_viewport(*self.texture_viewport) self._comm_toggles() self.fbuffer_prog['texture'] = self.fbuffer_tex_front self.fbuffer_prog.draw('triangle_strip') yield self.flush_geometry() self.transform_matrix = np.identity(4) gloo.set_viewport(*self.viewport) self._comm_toggles(False) self.clear() self.fbuffer_prog['texture'] = self.fbuffer_tex_back self.fbuffer_prog.draw('triangle_strip') self.fbuffer_tex_front, self.fbuffer_tex_back = self.fbuffer_tex_back, self.fbuffer_tex_front
Example #10
Source File: renderer2d.py From p5 with GNU General Public License v3.0 | 5 votes |
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)
Example #11
Source File: renderer.py From ssd-6d with MIT License | 5 votes |
def render_view_metrical_clip(self, model, pose, diameter): cut = self.compute_metrical_clip(pose, diameter) self.clear() self.draw_model(model, pose) col, dep = self.finish() return col[cut[0]:cut[2], cut[1]:cut[3]], dep[cut[0]:cut[2], cut[1]:cut[3]]
Example #12
Source File: renderer.py From ssd-6d with MIT License | 5 votes |
def clear(self): gloo.clear(color=True, depth=True)
Example #13
Source File: canvas.py From harvesters_gui with Apache License 2.0 | 5 votes |
def release_buffers(self): for _buffer in self._buffers: if _buffer: _buffer.queue() self._buffers.clear()
Example #14
Source File: renderer.py From patch_linemod with BSD 2-Clause "Simplified" License | 5 votes |
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()
Example #15
Source File: renderer.py From patch_linemod with BSD 2-Clause "Simplified" License | 5 votes |
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()
Example #16
Source File: renderer_xyz.py From Pix2Pose with MIT License | 5 votes |
def render_view_metrical_clip(self, model, pose, diameter): cut = self.compute_metrical_clip(pose, diameter) self.clear() self.draw_model(model, pose) col, dep = self.finish() return col[cut[0]:cut[2], cut[1]:cut[3]], dep[cut[0]:cut[2], cut[1]:cut[3]]
Example #17
Source File: renderer_xyz.py From Pix2Pose with MIT License | 5 votes |
def clear(self): gloo.clear(color=True, depth=True)
Example #18
Source File: renderer.py From Pix2Pose with MIT License | 5 votes |
def clear(self): gloo.clear(color=True, depth=True)
Example #19
Source File: renderer2d.py From p5 with GNU General Public License v3.0 | 4 votes |
def reset_view(self): self.viewport = ( 0, 0, int(builtins.width * builtins.pixel_x_density), int(builtins.height * builtins.pixel_y_density), ) self.texture_viewport = ( 0, 0, builtins.width, builtins.height, ) gloo.set_viewport(*self.viewport) cz = (builtins.height / 2) / math.tan(math.radians(30)) self.projection_matrix = matrix.perspective_matrix( math.radians(60), builtins.width / builtins.height, 0.1 * cz, 10 * cz ) self.modelview_matrix = matrix.translation_matrix(-builtins.width / 2, \ builtins.height / 2, \ -cz) self.modelview_matrix = self.modelview_matrix.dot(matrix.scale_transform(1, -1, 1)) self.transform_matrix = np.identity(4) self.default_prog['modelview'] = self.modelview_matrix.T.flatten() self.default_prog['projection'] = self.projection_matrix.T.flatten() self.texture_prog['modelview'] = self.modelview_matrix.T.flatten() self.texture_prog['projection'] = self.projection_matrix.T.flatten() self.line_prog = Program(src_line.vert, src_line.frag) self.line_prog['modelview'] = self.modelview_matrix.T.flatten() self.line_prog['projection'] = self.projection_matrix.T.flatten() self.line_prog["height"] = builtins.height self.fbuffer_tex_front = Texture2D((builtins.height, builtins.width, 3)) self.fbuffer_tex_back = Texture2D((builtins.height, builtins.width, 3)) for buf in [self.fbuffer_tex_front, self.fbuffer_tex_back]: self.fbuffer.color_buffer = buf with self.fbuffer: self.clear()
Example #20
Source File: canvas.py From harvesters_gui with Apache License 2.0 | 4 votes |
def on_draw(self, event): # Update on June 15th, 2018: # According to a VisPy developer, they have not finished # porting VisPy to PyQt5. Once they finished the development # we should try it out if it gives us the maximum refresh rate. # See the following URL to check the latest information: # # https://github.com/vispy/vispy/issues/1394 # Clear the canvas in gray. gloo.clear(color=self._background_color) drew = False try: if not self._pause_drawing: # Fetch a buffer. buffer = self.ia.fetch_buffer(timeout=0.0001) # Prepare a texture to draw: self._prepare_texture(buffer) # Draw the texture until the buffer object exists # within this scope: # (We keep the buffer until the next one is delivered to # keep the current chunk data alive but it depends on the # application; we just want to tell you that the texture # must be overdrawn until the content is alive:) self._draw() # Release the buffers that we've kept holding so far: self.release_buffers() # We have drawn the latest image on the canvas: drew = True # Keep the buffer alive to keep the chunk data alive until # the next one is delivered: self._buffers.append(buffer) except AttributeError: # Calling fetch_buffer() raises AttributeError because # the ImageAcquirer object is None. pass except TimeoutException: # We have an ImageAcquirer object but nothing has # been fetched, wait for the next round: pass # Draw the latest texture again if needed: if not drew: self._draw()