当前位置: 首页>>代码示例>>Python>>正文


Python bgl.glClear方法代码示例

本文整理汇总了Python中bgl.glClear方法的典型用法代码示例。如果您正苦于以下问题:Python bgl.glClear方法的具体用法?Python bgl.glClear怎么用?Python bgl.glClear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bgl的用法示例。


在下文中一共展示了bgl.glClear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: offscreen_refresh

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glClear [as 别名]
def offscreen_refresh(self, context):
        if self.offscreen is not None:
            self.offscreen.free()

        width = self.region.width
        height = self.region.height
        self.offscreen = gpu.types.GPUOffScreen(width, height)

        mat_offscreen = Matrix()
        mat_offscreen[0][0] = 2 / width
        mat_offscreen[0][3] = -1
        mat_offscreen[1][1] = 2 / height
        mat_offscreen[1][3] = -1

        with self.offscreen.bind():
            bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)

            with gpu.matrix.push_pop():
                gpu.matrix.load_matrix(mat_offscreen)
                gpu.matrix.load_projection_matrix(Matrix())

                self.draw_gems(context) 
开发者ID:mrachinskiy,项目名称:jewelcraft,代码行数:24,代码来源:offscreen.py

示例2: render_opengl_image

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glClear [as 别名]
def render_opengl_image(image_name, cam, point_size):
    draw_manager = DrawManager.get_singleton()
    coords, colors = draw_manager.get_coords_and_colors()

    scene = bpy.context.scene
    render = bpy.context.scene.render

    width = render.resolution_x
    height = render.resolution_y
    # TODO Provide an option to render from the 3D view perspective
    # width = bpy.context.region.width
    # height = bpy.context.region.height

    offscreen = gpu.types.GPUOffScreen(width, height)
    with offscreen.bind():

        bgl.glPointSize(point_size)
        #bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)
        #bgl.glClear(bgl.GL_DEPTH_BUFFER_BIT)

        view_matrix = cam.matrix_world.inverted()
        projection_matrix = cam.calc_matrix_camera(
            bpy.context.evaluated_depsgraph_get(), 
            x=width,
            y=height)
        perspective_matrix = projection_matrix @ view_matrix

        gpu.matrix.load_matrix(perspective_matrix)
        gpu.matrix.load_projection_matrix(Matrix.Identity(4))
        
        shader = gpu.shader.from_builtin('3D_FLAT_COLOR')
        shader.bind()
        batch = batch_for_shader(shader, "POINTS", {"pos": coords, "color": colors})
        batch.draw(shader)
        
        buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4)
        bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)

    offscreen.free()

    image = create_image_lazy(image_name, width, height)
    copy_buffer_to_pixel(buffer, image) 
开发者ID:SBCV,项目名称:Blender-Addon-Photogrammetry-Importer,代码行数:44,代码来源:opengl_utils.py

示例3: draw_callback_px

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glClear [as 别名]
def draw_callback_px(context):
    # Note that the "context" passed in here is a regular dictionary and not the Blender context
    global screen_display_lines
    pid = None
    if 'mcell' in bpy.context.scene:
      mcell = bpy.context.scene.mcell
      if 'run_simulation' in mcell:
        rs = mcell.run_simulation
        if len(rs.processes_list) > 0:
          pid_str = rs.processes_list[rs.active_process_index].name
          pid = pid_str.split(',')[0].split()[1]

    bgl.glPushAttrib(bgl.GL_ENABLE_BIT)

    if parameter_dictionary['Clear']['val']:
      bgl.glClearColor ( 0.0, 0.0, 0.0, 1.0 )
      bgl.glClear ( bgl.GL_COLOR_BUFFER_BIT )

    font_id = 0  # XXX, need to find out how best to get this.

    y_pos = 15 * (scroll_offset + 1)
    if pid and (pid in screen_display_lines):
      for l in screen_display_lines[pid]:
          blf.position(font_id, 15, y_pos, 0)
          y_pos += 15
          blf.size(font_id, 14, 72) # fontid, size, DPI
          bgl.glColor4f(1.0, 1.0, 1.0, 0.5)
          blf.draw(font_id, l)
    else:
      keys = screen_display_lines.keys()
      for k in keys:
          for l in screen_display_lines[k]:
              blf.position(font_id, 15, y_pos, 0)
              y_pos += 15
              blf.size(font_id, 14, 72) # fontid, size, DPI
              bgl.glColor4f(1.0, 1.0, 1.0, 0.5)
              blf.draw(font_id, l)

    # 100% alpha, 2 pixel width line
    bgl.glEnable(bgl.GL_BLEND)

    bgl.glPopAttrib()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
开发者ID:mcellteam,项目名称:cellblender,代码行数:49,代码来源:__init__.py


注:本文中的bgl.glClear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。