本文整理汇总了Python中vispy.gloo.clear方法的典型用法代码示例。如果您正苦于以下问题:Python gloo.clear方法的具体用法?Python gloo.clear怎么用?Python gloo.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vispy.gloo
的用法示例。
在下文中一共展示了gloo.clear方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
def clear(self):
gloo.clear(color=True, depth=True)
示例2: render_view_metrical_clip
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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]]
示例3: draw_color
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [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()
示例4: draw_depth
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [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()
示例5: release_buffers
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
def release_buffers(self):
for _buffer in self._buffers:
if _buffer:
_buffer.queue()
self._buffers.clear()
示例6: clear
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [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)
示例7: draw_loop
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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
示例8: reset_view
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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))
示例9: on_draw
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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')
示例10: clear
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
def clear(self, color=True, depth=True):
gloo.clear(color=color, depth=True)
示例11: draw_background
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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
示例12: draw_coordinate_system
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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)
示例13: on_draw
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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()
示例14: reset_view
# 需要导入模块: from vispy import gloo [as 别名]
# 或者: from vispy.gloo import clear [as 别名]
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()