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


Python bgl.GL_RGBA属性代码示例

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


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

示例1: _update_texture

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_RGBA [as 别名]
def _update_texture(self, scene):
        if self._transparent:
            gl_format = bgl.GL_RGBA
            internal_format = bgl.GL_RGBA32F
        else:
            gl_format = bgl.GL_RGB
            internal_format = bgl.GL_RGB32F

        bgl.glActiveTexture(bgl.GL_TEXTURE0)
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
        bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, internal_format, self._width, self._height,
                         0, gl_format, bgl.GL_FLOAT, self.buffer)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_S, bgl.GL_CLAMP_TO_EDGE)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_T, bgl.GL_CLAMP_TO_EDGE)

        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
        mag_filter = bgl.GL_NEAREST if scene.luxcore.viewport.mag_filter == "NEAREST" else bgl.GL_LINEAR
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, mag_filter)
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, NULL) 
开发者ID:LuxCoreRender,项目名称:BlendLuxCore,代码行数:21,代码来源:viewport.py

示例2: buffer_image

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_RGBA [as 别名]
def buffer_image(self):
        if not self.loaded: return
        if self.buffered: return
        if self.deleted: return
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
        bgl.glTexEnvf(bgl.GL_TEXTURE_ENV, bgl.GL_TEXTURE_ENV_MODE, bgl.GL_MODULATE)
        bgl.glTexParameterf(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST)
        bgl.glTexParameterf(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_LINEAR)
        # texbuffer = bgl.Buffer(bgl.GL_BYTE, [self.width,self.height,self.depth], image_data)
        image_size = self.image_width*self.image_height*self.image_depth
        texbuffer = bgl.Buffer(bgl.GL_BYTE, [image_size], self.image_flat)
        bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, bgl.GL_RGBA, self.image_width, self.image_height, 0, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, texbuffer)
        del texbuffer
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)
        self.buffered = True 
开发者ID:CGCookie,项目名称:addon_common,代码行数:17,代码来源:ui.py

示例3: __init__

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_RGBA [as 别名]
def __init__(self, engine, context, scene):
        filmsize = utils.calc_filmsize(scene, context)
        self._width, self._height = filmsize
        self._border = utils.calc_blender_border(scene, context)
        self._offset_x, self._offset_y = self._calc_offset(context, scene, self._border)
        self._pixel_size = int(scene.luxcore.viewport.pixel_size)

        if utils.is_valid_camera(scene.camera) and not utils.in_material_shading_mode(context):
            pipeline = scene.camera.data.luxcore.imagepipeline
            self._transparent = pipeline.transparent_film
        else:
            self._transparent = False

        if self._transparent:
            bufferdepth = 4
            self._buffertype = bgl.GL_RGBA
            self._output_type = pyluxcore.FilmOutputType.RGBA_IMAGEPIPELINE
        else:
            bufferdepth = 3
            self._buffertype = bgl.GL_RGB
            self._output_type = pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE

        self.buffer = bgl.Buffer(bgl.GL_FLOAT, [self._width * self._height * bufferdepth])
        self._init_opengl(engine, scene)

        # Denoiser
        self._noisy_file_path = self._make_denoiser_filepath("noisy")
        self._albedo_file_path = self._make_denoiser_filepath("albedo")
        self._normal_file_path = self._make_denoiser_filepath("normal")
        self._denoised_file_path = self._make_denoiser_filepath("denoised")
        current_dir = dirname(os.path.realpath(__file__))
        addon_dir = dirname(current_dir)  # Go up one level
        self._denoiser_path = which("oidnDenoise",
                                    path=os.path.join(addon_dir, "bin") + os.pathsep + os.environ["PATH"])
        self._denoiser_process = None
        self.denoiser_result_cached = False 
开发者ID:LuxCoreRender,项目名称:BlendLuxCore,代码行数:38,代码来源:viewport.py

示例4: render_opengl_image

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_RGBA [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


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