cgv
Loading...
Searching...
No Matches
cgv::render::color_scale_adapter Class Reference

Manages graphics resources to enable using device_color_scale in shader programs. More...

#include <color_scale_adapter.h>

Public Member Functions

bool init (const context &ctx)
 Initialize the color_scale_adapter.
 
bool destruct (const context &ctx)
 Destruct the color_scale_adapter.
 
bool enable (const context &ctx, int texture_unit)
 Enable the managed render resources to prepare for rendering.
 
bool disable (const context &ctx)
 Disable the managed render resources after rendering.
 
void set_uniforms_in_program (context &ctx, shader_program &prog, int texture_unit)
 Set texture unit and uniform buffer location in the given shader_program and prepare uniform buffer.
 
void set_color_scale (std::shared_ptr< const device_color_scale > color_scale)
 Set a reference to a single device_color_scale to be managed by this color_scale_adapter.
 
void set_color_scales (const std::vector< std::shared_ptr< const device_color_scale > > &color_scales)
 Set a reference to multiple device_color_scales to be managed by this color_scale_adapter.
 
size_t get_supported_color_scale_count () const
 Get the number of maximally supported device_color_scales.
 
textureget_texture (const context &ctx)
 Get the texture containing the device_color_scales' color data.
 

Detailed Description

Manages graphics resources to enable using device_color_scale in shader programs.

color_scale_adapter can store a reference to one or more device_color_scales and handles automatic texture and uniform buffer creation to enable using color_scales in shader programs that use the interface from color_scale.glsl. The texture is only updated if new device_color_scales are set or the referenced device_color_scales are modified as detected through color_scale::get_modified_time().

Definition at line 22 of file color_scale_adapter.h.

Member Function Documentation

◆ destruct()

bool cgv::render::color_scale_adapter::destruct ( const context ctx)

Destruct the color_scale_adapter.

Destructs the used buffers. No method may be called after this, except init().

Parameters
ctxThe CGV rendering context.
Returns
True if successful, false otherwise.

Definition at line 10 of file color_scale_adapter.cxx.

References cgv::render::texture::destruct().

Referenced by cgv::plot::plot_base::clear().

◆ disable()

bool cgv::render::color_scale_adapter::disable ( const context ctx)

Disable the managed render resources after rendering.

Parameters
ctxThe CGV rendering context.
Returns
True if successful, false otherwise.

Definition at line 27 of file color_scale_adapter.cxx.

References cgv::render::texture::disable().

Referenced by cgv::plot::plot3d::draw().

◆ enable()

bool cgv::render::color_scale_adapter::enable ( const context ctx,
int  texture_unit 
)

Enable the managed render resources to prepare for rendering.

Parameters
ctxThe CGV rendering context.
texture_unitThe texture unit used for the color scale texture. Must match the value used in set_uniforms_in_program().
Returns
True if successful, false otherwise.

Definition at line 15 of file color_scale_adapter.cxx.

References cgv::render::texture::enable().

Referenced by cgv::plot::plot3d::draw().

◆ get_supported_color_scale_count()

size_t cgv::render::color_scale_adapter::get_supported_color_scale_count ( ) const
inline

Get the number of maximally supported device_color_scales.

Returns
The count.

Definition at line 72 of file color_scale_adapter.h.

◆ get_texture()

texture & cgv::render::color_scale_adapter::get_texture ( const context ctx)

Get the texture containing the device_color_scales' color data.

Parameters
ctxThe CGV rendering context.
Returns
The texture. Todo: Return as const reference. Need to make texture enable/disable const to be able to use the returned texture. However, this is not so simple as texture::enable() calls a method from the context which will modify texture_base which is then also const.

Definition at line 67 of file color_scale_adapter.cxx.

◆ init()

bool cgv::render::color_scale_adapter::init ( const context ctx)

Initialize the color_scale_adapter.

Initializes the used buffers. Needs to be called first before any other method.

Parameters
ctxThe CGV rendering context.
Returns
True if successful, false otherwise.

Definition at line 6 of file color_scale_adapter.cxx.

Referenced by cgv::plot::plot_base::init().

◆ set_color_scale()

void cgv::render::color_scale_adapter::set_color_scale ( std::shared_ptr< const device_color_scale color_scale)

Set a reference to a single device_color_scale to be managed by this color_scale_adapter.

Parameters
color_scaleThe adapted device_color_scale.

Definition at line 48 of file color_scale_adapter.cxx.

◆ set_color_scales()

void cgv::render::color_scale_adapter::set_color_scales ( const std::vector< std::shared_ptr< const device_color_scale > > &  color_scales)

Set a reference to multiple device_color_scales to be managed by this color_scale_adapter.

Will only store references to the first get_supported_color_scale_count() passed device_color_scales.

Parameters
color_scalesThe adapted device_color_scales.

Definition at line 57 of file color_scale_adapter.cxx.

Referenced by cgv::plot::plot_base::set_mapping_uniforms().

◆ set_uniforms_in_program()

void cgv::render::color_scale_adapter::set_uniforms_in_program ( context ctx,
shader_program prog,
int  texture_unit 
)

Set texture unit and uniform buffer location in the given shader_program and prepare uniform buffer.

Parameters
ctxThe CGV rendering context.
progThe shader_program used for rendering. Must be linked against color_scale.glsl.
texture_unitThe texture unit used for the color scale texture. Must match the value used in enable().

Definition at line 32 of file color_scale_adapter.cxx.

References cgv::render::shader_program::disable(), cgv::render::shader_program::enable(), cgv::render::shader_program::is_enabled(), and cgv::render::shader_program::set_uniform().

Referenced by cgv::plot::plot_base::set_mapping_uniforms().


The documentation for this class was generated from the following files: