picogl.backend.gl.driver.blend
A driver for managing OpenGL blending functionality.
This module provides a driver class for configuring and applying blending settings using OpenGL. It interacts with low-level OpenGL capabilities and provides methods for enabling blending, setting blending functions, and updating blending states. The driver works in conjunction with the capability driver and state objects to manage blending-related operations efficiently.
Classes
GLBlendDriver |
Module Contents
- class picogl.backend.gl.driver.blend.GLBlendDriver(capabilities: picogl.backend.gl.driver.capability.GLCapabilityDriver)[source]
Bases:
picogl.backend.gl.driver.applicable_state.ApplicableStateGLBlendDriver
- set_blend(enabled: bool)[source]
Sets the blending capability for the pipeline.
This method updates the blending state of the pipeline by enabling or disabling the blending functionality, which determines how pixels are blended together when rendered.
- Parameters:
enabled (bool) – Specifies whether the blending capability should be enabled
disabled ((True) or)
- static set_blend_func(src: picogl.backend.gl.capability.GLBlendFactor | int, dst: picogl.backend.gl.capability.GLBlendFactor | int)[source]
Sets the blending function for OpenGL rendering.
This method specifies how the colors of a source and destination are combined to produce a final color in OpenGL. The blending function is defined by the source and destination blend factors. These factors determine the influence of the source (incoming) and destination (existing framebuffer) pixel values during blending.
- Parameters:
src (GLBlendFactor | int) – The source blending factor. This determines how the incoming pixel color contributes to the final blended color.
dst (GLBlendFactor | int) – The destination blending factor. This determines how the existing framebuffer pixel color contributes to the final blended color.
- Returns:
None
- static get_blend_func() tuple[picogl.backend.gl.capability.GLBlendFactor, picogl.backend.gl.capability.GLBlendFactor][source]
Retrieves the current OpenGL blend function factors for the source and destination.
- Returns:
A tuple containing the source and destination blend factors as GLBlendFactor instances.
- Return type:
- set_alpha_blending()[source]
Sets the alpha blending mode for rendering.
Alpha blending is configured by specifying source and destination blend functions. This method sets the blend function to use the source alpha channel and the inverse of the source alpha channel for blending.
- Raises:
Any exceptions raised by set_blend_func method will be propagated. –
- _do_apply(state: BlendState | None, prev: BlendState | None)[source]
Performs the application of a new blending state to the current render state.
This method compares the provided blending state with the previous state and applies necessary changes based on the differences. If no new blending state is specified, the method exits without making any changes.
- Parameters:
state (BlendState | None) – The new blending state to apply. If None, no changes will be made to the current state.
prev (BlendState | None) – The previous blending state. Used to determine which properties have changed and need to be applied to the current state.
- _is_same(prev: picogl.backend.state.BlendState, state: picogl.backend.state.BlendState) bool[source]
Determines if two BlendState instances are equal.
This function compares two BlendState objects and returns a boolean indicating if they are equivalent.
Parameters: prev : BlendState
The first BlendState object to compare.
- stateBlendState
The second BlendState object to compare.
Returns: bool
True if the two BlendState objects are equal, otherwise False.