cgv
|
the texture class encapsulates all functionality independent of the rendering api. More...
#include <texture.h>
Public Member Functions | |
methods that can be called without context | |
texture (const std::string &description="uint8[R,G,B,A]", TextureFilter _mag_filter=TF_LINEAR, TextureFilter _min_filter=TF_LINEAR, TextureWrap _wrap_s=TW_CLAMP_TO_EDGE, TextureWrap _wrap_t=TW_CLAMP_TO_EDGE, TextureWrap _wrap_r=TW_CLAMP_TO_EDGE) | |
construct from description string (which defaults to rgba format) and most commonly used texture parameters. | |
~texture () | |
destruct texture, the destructor can be called without context if the destruct method has been called or no creation has taken place | |
bool | set_data_format (const std::string &description) |
change the data format and clear internal format | |
void | set_component_format (const component_format &cf) |
change component format and clear internal format | |
void | set_component_format (const std::string &description) |
change component format and clear internal format | |
void | set_wrap_s (TextureWrap _wrap_s) |
set the texture wrap behaviour in s direction | |
void | set_wrap_t (TextureWrap _wrap_t) |
set the texture wrap behaviour in t direction | |
void | set_wrap_r (TextureWrap _wrap_r) |
set the texture wrap behaviour in r direction | |
TextureWrap | get_wrap_s () const |
return the texture wrap behaviour in s direction | |
TextureWrap | get_wrap_t () const |
return the texture wrap behaviour in t direction | |
TextureWrap | get_wrap_r () const |
return the texture wrap behaviour in r direction | |
void | set_border_color (const float *rgba) |
set the border color | |
void | set_border_color (float r, float g, float b, float a=1.0f) |
set the border color | |
void | set_min_filter (TextureFilter _min_filter, float _anisotropy=2.0f) |
set the minification filters, if minification is set to TF_ANISOTROP, the second floating point parameter specifies the degree of anisotropy | |
TextureFilter | get_min_filter () const |
return the minification filter | |
float | get_anisotropy () const |
return the currently set anisotropy | |
void | set_mag_filter (TextureFilter _mag_filter) |
set the magnification filter | |
TextureFilter | get_mag_filter () const |
return the magnification filter | |
void | set_priority (float _priority) |
set priority with which texture is kept in GPU memory | |
float | get_priority () const |
return the priority with which texture is kept in GPU memory | |
void | set_compare_mode (bool use_compare_function) |
set the texture compare mode and function | |
bool | get_compare_mode () const |
get the texture compare mode and function | |
void | set_compare_function (CompareFunction compare_function) |
set the texture compare function | |
CompareFunction | get_compare_function () const |
get the texture compare function | |
bool | mipmaps_created () const |
check whether mipmaps have been created | |
void | set_nr_multi_samples (unsigned _nr_samples) |
set the number of multi samples for textures of type TT_MULTISAMPLE_2D and TT_MULTISAMPLE_2D_ARRAY | |
unsigned | get_nr_multi_samples () const |
return number of multi samples for textures of type TT_MULTISAMPLE_2D and TT_MULTISAMPLE_2D_ARRAY | |
bool | use_fixed_sample_locations () const |
whether multi sampling uses fixed sample locations | |
void | set_fixed_sample_locations (bool use) |
set whether multi sampling uses fixed sample locations | |
void | ensure_state (const context &ctx) const |
ensure the the texture state is synchronized with the GPU settings | |
bool | is_enabled () const |
check whether textue is enabled | |
int | get_tex_unit () const |
return the currently used texture unit and -1 for current | |
methods that change the current gpu context | |
bool | enable (const context &ctx, int tex_unit=-1) |
enable this texture in the given texture unit, -1 corresponds to the current unit. | |
bool | disable (const context &ctx) |
disable texture and restore state from before last enable call | |
bool | bind_as_image (const context &ctx, int tex_unit, int level=0, bool bind_array=false, int layer=0, AccessType access=AT_WRITE_ONLY) |
Binds this texture as an image texture to the given texture unit. | |
![]() | |
texture_base (TextureType _tt=TT_UNDEF) | |
initialize members | |
![]() | |
render_component () | |
initialize members | |
virtual bool | is_created () const |
return whether component has been created | |
void | put_id_void (void *ptr) const |
copy the rendering api specific id the component to the memory location of the given pointer. | |
template<typename T > | |
void | put_id (T &id) const |
cast the refence to rendering api specific representation of component id to the specified type | |
![]() | |
data_format () | |
construct an undefined data format | |
data_format (const std::string &description) | |
construct from description string, see set_data_format for docu | |
bool | set_data_format (const std::string &description) |
Set data format from description string, which adds information to the description string of the component format and has the following syntax. | |
data_format (size_t _width, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 1d data format from width and the information needed to construct a component info | |
data_format (size_t _width, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 1d data format from width and the information needed to construct a component info | |
data_format (size_t _width, size_t _height, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 2d data format from width and height | |
data_format (size_t _width, size_t _height, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 2d data format from width and height | |
data_format (size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 3d data format from width, height and depth | |
data_format (size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 3d data format from width, height and depth | |
data_format (size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 4d data format from width, height, depth and count | |
data_format (size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct a 4d data format from width, height, depth and count | |
void | set_dimensions (size_t _d0, size_t _d1=-1, size_t _d2=-1, size_t _d3=-1) |
set the dimensions to the given values | |
unsigned | get_nr_dimensions () const |
return the number of dimensions of the data set | |
void | set_nr_dimensions (unsigned _d) |
set the number of dimensions of the data set | |
size_t | get_resolution (unsigned i) const |
return the resolution in the i-th dimension, or 0 if not defined | |
size_t | get_width () const |
return the resolution in the first dimension, or 1 if not defined | |
size_t | get_height () const |
return the resolution in the second dimension, or 1 if not defined | |
size_t | get_depth () const |
return the resolution in the third dimension, or 1 if not defined | |
size_t | get_nr_time_steps () const |
return the resolution in the highest dimension, or 1 if not defined | |
size_t | get_nr_entries () const |
return the total number of data entries | |
size_t | get_nr_bytes () const |
return the total number of bytes necessary to store the data | |
void | set_resolution (unsigned i, size_t resolution) |
set the resolution in the i-th dimension, add dimensions if necessary | |
void | set_width (size_t _width) |
set the resolution in the first dimension, add dimensions if necessary | |
void | set_height (size_t _height) |
set the resolution in the second dimension, add dimensions if necessary | |
void | set_depth (size_t _depth) |
set the resolution in the third dimension, add dimensions if necessary | |
void | set_nr_time_steps (size_t _nr_time_steps) |
set the resolution in the last dimension, add dimensions if necessary | |
unsigned | get_entry_alignment () const |
return the alignment of entries | |
unsigned | get_alignment (unsigned i) const |
return the alignment of a given dimension, where the alignment of the last dimension is always 1 and cannot be changed. | |
void | set_entry_alignment (unsigned _a) |
set the alignment of entries | |
void | set_alignment (unsigned i, unsigned _a) |
set the alignment of a given dimension, add dimensions if necessary. | |
unsigned | get_layout_dimension (unsigned dim) const |
return the layout dimension of a given dimension | |
void | set_layout_dimension (unsigned dim, unsigned layout_dim) |
set the layout dimension of a given dimension, add dimensions if necessary | |
const component_format & | get_component_format () const |
return the component_format info by simple conversion of the this pointer | |
void | set_component_format (const component_format &cf) |
set component_format by simply assigning to a converted this pointer | |
bool | operator== (const data_format &df) const |
comparison between component formats | |
bool | operator!= (const data_format &df) const |
comparison between component formats | |
![]() | |
component_format (const std::string &description) | |
construct from description string, see set_component_format for docu | |
bool | set_component_format (const std::string &description) |
set component format from description string, which has the following syntax. | |
void | set_components (const std::string &_components) |
comma separated list of component descriptors, for example "R,G,B" | |
component_format (cgv::type::info::TypeId _component_type=cgv::type::info::TypeId::TI_UNDEF, const std::string &_component_name_list="", unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats | |
component_format (cgv::type::info::TypeId _component_type, ComponentFormat cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct component format from component type, standard component format, component alignment and bit depths for packed formats | |
void | set_integer_interpretation (ComponentIntegerInterpretation cii) |
set the integer interpretation | |
ComponentIntegerInterpretation | get_integer_interpretation () const |
return current integer interpretation | |
template<typename T > | |
T | get (int ci, const void *ptr) const |
constant access to the i-th component stored at the given location | |
template<typename T > | |
bool | set (int ci, void *ptr, const T &v) const |
write access to the i-th component, return whether write was successful | |
bool | empty () const |
return whether the component format is defined | |
void | clear () |
clear the component format | |
const packing_info & | get_packing_info () const |
return the packing info by simple conversion of the this pointer | |
void | set_packing_info (const packing_info &pi) |
set packing info by simply assigning to a converted this pointer | |
unsigned int | get_nr_components () const |
return the number of components | |
unsigned int | get_component_index (const std::string &name) const |
return the index of a component given by name or -1 if not found | |
std::string | get_component_name (unsigned int i) const |
return the name of the component with index i | |
ComponentFormat | get_standard_component_format () const |
return whether the component format is one of the standard formats | |
void | set_component_names (const std::string &_component_name_list) |
set component names from a comma or colon separated list of names | |
void | set_component_format (ComponentFormat _cf) |
set the component names from a standard component format | |
cgv::type::info::TypeId | get_component_type () const |
return the component type | |
void | set_component_type (cgv::type::info::TypeId _type_id) |
set the component type | |
unsigned int | get_entry_size () const |
return the size of one entry of components in bytes | |
bool | operator== (const component_format &cf) const |
comparison between component formats | |
bool | operator!= (const component_format &cf) const |
comparison between component formats | |
![]() | |
packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct packing information from alignment and bit depths. | |
void | clear () |
clear packing info information | |
unsigned | get_bit_depth (unsigned ci) const |
return the bit depth of the ci-th component | |
void | set_bit_depth (unsigned ci, unsigned depth) |
set the bit depth of the ci-th component | |
bool | is_packing () const |
return whether packing is enabled | |
void | set_packing (bool enable=true) |
set the packing flag | |
unsigned int | get_component_alignment () const |
return the component alignment in bits in the packed case and in bytes in the unpacked case | |
void | set_component_alignment (unsigned a) |
set the component alignment in bits in the packed case and in bytes in the unpacked case | |
int | get_signed (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
unsigned int | get_unsigned (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | set_signed (unsigned ci, void *ptr, int v) const |
set the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
bool | set_unsigned (unsigned ci, void *ptr, unsigned v) const |
set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | operator== (const packing_info &pi) const |
equal comparison | |
bool | operator!= (const packing_info &pi) const |
unequal comparison | |
Public Attributes | |
std::string | last_error |
a string that contains the last error | |
![]() | |
TextureFilter | mag_filter |
TextureFilter | min_filter |
TextureWrap | wrap_s |
TextureWrap | wrap_t |
TextureWrap | wrap_r |
float | anisotropy |
float | priority |
float | border_color [4] |
CompareFunction | compare_function |
bool | use_compare_function |
TextureType | tt |
bool | have_mipmaps |
unsigned | nr_multi_samples = 5 |
bool | fixed_sample_locations = true |
![]() | |
void * | handle |
void * | internal_format |
void * | user_data |
const context * | ctx_ptr |
keep pointer to my context | |
std::string | last_error |
a string that contains the last error | |
Protected Member Functions | |
methods that can be called only with a context | |
bool | complete_create (const context &ctx, bool created) |
![]() | |
void | extract_components () |
extract components from component string | |
![]() | |
bool | prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const |
bool | prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const |
unsigned int | get_bit_offset (unsigned ci) const |
Protected Attributes | |
bool | state_out_of_date |
int | tex_unit |
![]() | |
std::vector< dimension_info > | dimensions |
store for each dimension resolution and alignment in a dimension_info struct | |
![]() | |
cgv::type::info::TypeId | component_type |
store the type id of the component type | |
ComponentIntegerInterpretation | component_interpretation |
interpretation of integer typed components | |
std::string | component_string |
store all component names in one string separated with 0-chars | |
std::vector< unsigned short > | component_positions |
store the position of each component in the component string | |
![]() | |
bool | is_packed: 1 |
unsigned | bd0: 6 |
unsigned | bd1: 6 |
unsigned | bd2: 6 |
unsigned | bd3: 6 |
unsigned | ca: 6 |
methods that can be called only with a context | |
void | find_best_format (const context &ctx, const std::vector< cgv::data::data_view > *palettes=0) |
find the format that matches the one specified in the component format best | |
bool | create (const context &ctx, TextureType _tt=TT_UNDEF, unsigned width=-1, unsigned height=-1, unsigned depth=-1) |
create the texture of dimension and resolution specified in the data format base class. | |
bool | create_from_image (const context &ctx, const std::string &file_name="", int *image_width_ptr=0, int *image_height_ptr=0, unsigned char *clear_color_ptr=0, int level=-1, int cube_side=-1) |
create the texture from an image file. | |
bool | create_from_image (cgv::data::data_format &df, cgv::data::data_view &dv, const context &ctx, const std::string &file_name="", unsigned char *clear_color_ptr=0, int level=-1, int cube_side=-1) |
same as previous method but use the passed data format and data view to store the content of the image. | |
bool | create_from_images (const context &ctx, const std::string &file_names, int level=-1) |
Create a cube map from six files specified in the file_names parameter. | |
bool | write_to_file (context &ctx, const std::string &file_name, unsigned int z_or_cube_side=-1, float depth_map_gamma=1.0f, const std::string &options="") const |
write the content of the texture to a file. This method needs support for frame buffer objects. | |
bool | create_mipmaps (const context &ctx) |
create storage for mipmaps without computing the mipmap contents | |
bool | generate_mipmaps (const context &ctx) |
generate mipmaps automatically, only supported if framebuffer objects are supported by the GPU | |
bool | create_from_buffer (const context &ctx, int x, int y, int width, int height, int level=-1) |
create texture from the currently set read buffer, where x, y, width and height define the to be used rectangle of the read buffer. | |
bool | create (const context &ctx, const cgv::data::const_data_view &data, int level=-1, int cube_side=-1, int num_array_layers=0, const std::vector< cgv::data::data_view > *palettes=0) |
create texture from data view. | |
bool | replace (const context &ctx, int x, const cgv::data::const_data_view &data, int level=-1, const std::vector< cgv::data::data_view > *palettes=0) |
replace a block within a 1d texture with the given data. | |
bool | replace (const context &ctx, int x, int y, const cgv::data::const_data_view &data, int level=-1, const std::vector< cgv::data::data_view > *palettes=0) |
replace a block within a 2d texture with the given data. | |
bool | replace (const context &ctx, int x, int y, int z_or_cube_side, const cgv::data::const_data_view &data, int level=-1, const std::vector< cgv::data::data_view > *palettes=0) |
replace a block within a 3d texture or a side of a cube map with the given data. | |
bool | replace_from_buffer (const context &ctx, int x, int y, int x_buffer, int y_buffer, int width, int height, int level=-1) |
replace a block within a 2d texture from the current read buffer. | |
bool | replace_from_buffer (const context &ctx, int x, int y, int z_or_cube_side, int x_buffer, int y_buffer, int width, int height, int level) |
replace a block within a 3d texture or a side from a cube map from the current read buffer. | |
bool | replace_from_image (const context &ctx, const std::string &file_name, int x, int y, int z_or_cube_side, int level) |
replace within a slice of a volume or a side of a cube map from the given image | |
bool | replace_from_image (cgv::data::data_format &df, cgv::data::data_view &dv, const context &ctx, const std::string &file_name, int x, int y, int z_or_cube_side, int level) |
same as previous method but use the passed data format and data view to store the content of the image. | |
bool | destruct (const context &ctx) |
destruct the texture and free texture memory and handle | |
static bool | deduce_file_names (const std::string &file_names, std::vector< std::string > &deduced_names) |
Helper function that determins the individual file names for a cubemap. | |
Additional Inherited Members | |
![]() | |
static const std::string & | get_last_error () |
returns an error string after parsing of description string has failed | |
![]() | |
static size_t | align (size_t v, unsigned a) |
return the next integer larger or equal to v which is dividable by a | |
![]() | |
static std::string | last_error |
store the last error that appeared during parsing of a description | |
the texture class encapsulates all functionality independent of the rendering api.
cgv::render::texture::texture | ( | const std::string & | description = "uint8[R,G,B,A]" , |
TextureFilter | _mag_filter = TF_LINEAR , |
||
TextureFilter | _min_filter = TF_LINEAR , |
||
TextureWrap | _wrap_s = TW_CLAMP_TO_EDGE , |
||
TextureWrap | _wrap_t = TW_CLAMP_TO_EDGE , |
||
TextureWrap | _wrap_r = TW_CLAMP_TO_EDGE |
||
) |
construct from description string (which defaults to rgba format) and most commonly used texture parameters.
construct from description string and most commonly used texture parameters.
The description can define a component format as described in cgv::data::component_format::set_component_format()
or a data format as described in cgv::data::data_format::set_data_format()
.
Definition at line 22 of file texture.cxx.
cgv::render::texture::~texture | ( | ) |
destruct texture, the destructor can be called without context if the destruct method has been called or no creation has taken place
Definition at line 42 of file texture.cxx.
References cgv::render::render_component::ctx_ptr, destruct(), and cgv::render::context::make_current().
bool cgv::render::texture::bind_as_image | ( | const context & | ctx, |
int | tex_unit, | ||
int | level = 0 , |
||
bool | bind_array = false , |
||
int | layer = 0 , |
||
AccessType | access = AT_WRITE_ONLY |
||
) |
Binds this texture as an image texture to the given texture unit.
ctx | The graphics context. |
tex_unit | The texture unit the texture is bound to. |
level | The mipmap level of the texture to bind. |
bind_array | Only for array textures. If true, the complete texture array is bound and the layer ignored. If false, a single layer as specified by layer is bound. |
layer | Only for array textures. The array layer to bind. |
access | The access type: read, write, read and write. |
Definition at line 761 of file texture.cxx.
References ensure_state(), and cgv::render::render_component::last_error.
|
protected |
Definition at line 523 of file texture.cxx.
bool cgv::render::texture::create | ( | const context & | ctx, |
const cgv::data::const_data_view & | data, | ||
int | level = -1 , |
||
int | cube_side = -1 , |
||
int | num_array_layers = 0 , |
||
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
create texture from data view.
Use dimension and resolution of data view but the component format of the texture. If level is not specified or set to -1 mipmaps are generated. If cube_side is specified, and data view is 2D, create one of the six sides of a cubemap. If num_array_layers is not zero a texture array is created. Set num_array_layers to -1 to automatically choose the layer number based on the data view dimensions and size, e.g. a 2D/3D data view creates a 1D/2D array with layer count equal to height/depth. Set num_array_layers to > 0 to manually specify the layer count. This can be used to create a one layer 1D/2D texture array from a 1D/2D data view. Cubemap arrays are currently not suported.
Definition at line 566 of file texture.cxx.
References destruct(), find_best_format(), cgv::data::data_view_base::get_format(), cgv::data::component_format::get_nr_components(), cgv::data::data_format::get_nr_dimensions(), cgv::data::data_format::get_resolution(), cgv::render::render_component::is_created(), replace(), cgv::data::data_format::set_nr_dimensions(), and cgv::data::data_format::set_resolution().
bool cgv::render::texture::create | ( | const context & | ctx, |
TextureType | _tt = TT_UNDEF , |
||
unsigned | width = -1 , |
||
unsigned | height = -1 , |
||
unsigned | depth = -1 |
||
) |
create the texture of dimension and resolution specified in the data format base class.
create the texture of dimension and resolution specified in the data format base class
If no type is given, determine it from the format. If dimensions are given, they overwrite the dimensions in the texture format.
Definition at line 208 of file texture.cxx.
References destruct(), find_best_format(), cgv::render::render_component::is_created(), cgv::data::data_format::set_depth(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().
Referenced by cgv::render::build_render_info(), cgv::render::gl::gl_transparent_renderer::create_and_attach_texture(), create_from_image(), cgv::app::color_map_editor::init(), vr_test::init_frame(), cgv::render::a_buffer::init_frame(), cgv::render::gl::gl_depth_peeler::init_frame(), and cgv::render::volume_renderer::init_noise_texture().
bool cgv::render::texture::create_from_buffer | ( | const context & | ctx, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | level = -1 |
||
) |
create texture from the currently set read buffer, where x, y, width and height define the to be used rectangle of the read buffer.
The dimension and resolution of the texture format are updated automatically. If level is not specified or set to -1 mipmaps are generated.
Definition at line 538 of file texture.cxx.
References destruct(), find_best_format(), cgv::render::render_component::is_created(), replace_from_buffer(), cgv::data::data_format::set_height(), cgv::data::data_format::set_nr_dimensions(), and cgv::data::data_format::set_width().
bool cgv::render::texture::create_from_image | ( | cgv::data::data_format & | df, |
cgv::data::data_view & | dv, | ||
const context & | ctx, | ||
const std::string & | file_name = "" , |
||
unsigned char * | clear_color_ptr = 0 , |
||
int | level = -1 , |
||
int | cube_side = -1 |
||
) |
same as previous method but use the passed data format and data view to store the content of the image.
No pointers to width and height can be passed as this information is available in the data_format after the call.
Definition at line 258 of file texture.cxx.
References create(), destruct(), cgv::data::component_format::empty(), cgv::data::component_format::get_entry_size(), cgv::data::data_format::get_height(), cgv::media::image::image_reader::get_last_error(), cgv::data::data_view_impl< D, P >::get_ptr(), cgv::data::data_format::get_width(), cgv::render::render_component::last_error, cgv::media::image::image_reader::read_image(), cgv::media::image::image_reader::read_palette(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().
bool cgv::render::texture::create_from_image | ( | const context & | ctx, |
const std::string & | file_name = "" , |
||
int * | image_width_ptr = 0 , |
||
int * | image_height_ptr = 0 , |
||
unsigned char * | clear_color_ptr = 0 , |
||
int | level = -1 , |
||
int | cube_side = -1 |
||
) |
create the texture from an image file.
create the texture from an image file
If the file_name is not given ask the user interactively for a file name. The image dimensions are written to the optionally passed pointers image_width_ptr and image_height_ptr. In order to support mipmapping, the width and height of the texture must be powers of two. If the clear_color_ptr is given, the texture is automatically extended in size to powers of two. clear_color_ptr points to four bytes that specify a RGBA color used to fill texels that are inserted to ensure dimensions of powers of two. For creation of a side of a cubemap specify the cube_side parameter.
Definition at line 330 of file texture.cxx.
References create_from_image(), cgv::data::data_format::get_height(), and cgv::data::data_format::get_width().
Referenced by create_from_image(), create_from_images(), and cgv::render::textured_material::ensure_textures().
bool cgv::render::texture::create_from_images | ( | const context & | ctx, |
const std::string & | file_names, | ||
int | level = -1 |
||
) |
Create a cube map from six files specified in the file_names parameter.
The file_names parameter can specify different file names by the use of the wildchar symbol '*' or by curly brackets. When using '*' the files are loaded in alphanumerical order. The image files defining the cubemap sides must be in the order positive x, negative x, positive y, negative y, positive z and negative z. Some examples of specifying file names:
Different levels of the mipmap pyramid can be created in separate calls. If the level parameter is not specified or -1, the images are load to level 0 and a mipmap pyramid is built automatically. This method has no support for rescaling to power of two dimensions. If a mipmap is used, the image files should already have power of two dimensions.
Definition at line 410 of file texture.cxx.
References create_from_image(), deduce_file_names(), and destruct().
bool cgv::render::texture::create_mipmaps | ( | const context & | ctx | ) |
create storage for mipmaps without computing the mipmap contents
Definition at line 507 of file texture.cxx.
References cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
|
static |
Helper function that determins the individual file names for a cubemap.
Returns whether the file_names specification was correct. See comment to create_from_images for the syntax of the file_names parameter.
Definition at line 345 of file texture.cxx.
References cgv::utils::tokenizer::set_sep(), cgv::utils::tokenizer::set_ws(), and cgv::utils::to_string().
Referenced by create_from_images().
bool cgv::render::texture::destruct | ( | const context & | ctx | ) |
destruct the texture and free texture memory and handle
Definition at line 730 of file texture.cxx.
Referenced by cgv::app::color_map_editor::clear(), cgv::app::color_map_legend::clear(), cgv::app::color_selector::clear(), cgv::render::volume_renderer::clear(), create(), create(), cgv::render::gl::gl_transparent_renderer::create_and_attach_texture(), create_from_buffer(), create_from_image(), create_from_images(), cgv::render::a_buffer::destruct(), cgv::render::gl::gl_depth_peeler::destruct(), cgv::render::gl::gl_transparent_renderer::destruct(), cgv::app::color_map_editor::init(), vr_test::init_frame(), cgv::render::a_buffer::init_frame(), cgv::render::gl::gl_depth_peeler::init_frame(), cgv::render::gl::gl_transparent_renderer::init_frame(), cgv::render::volume_renderer::init_noise_texture(), and ~texture().
bool cgv::render::texture::disable | ( | const context & | ctx | ) |
disable texture and restore state from before last enable call
disable texture and restore state before last enable call
Definition at line 756 of file texture.cxx.
References cgv::data::data_format::get_nr_dimensions().
Referenced by cgv::render::gl::gl_transparent_renderer::blend_texture_over_viewport(), cgv::render::a_buffer::disable(), cgv::render::cone_renderer::disable(), cgv::render::volume_renderer::disable(), vr_test::draw(), cgv::render::gl::gl_depth_peeler::end_layer(), and vr_test::finish_draw().
bool cgv::render::texture::enable | ( | const context & | ctx, |
int | tex_unit = -1 |
||
) |
enable this texture in the given texture unit, -1 corresponds to the current unit.
Definition at line 745 of file texture.cxx.
References ensure_state(), cgv::data::data_format::get_nr_dimensions(), and cgv::render::render_component::last_error.
Referenced by cgv::render::gl::gl_depth_peeler::begin_layer(), cgv::render::gl::gl_transparent_renderer::blend_texture_over_viewport(), vr_test::draw(), cgv::render::cone_renderer::enable(), cgv::render::volume_renderer::enable(), cgv::render::a_buffer::enable(), and vr_test::finish_draw().
void cgv::render::texture::ensure_state | ( | const context & | ctx | ) | const |
ensure the the texture state is synchronized with the GPU settings
Definition at line 198 of file texture.cxx.
Referenced by cgv::render::frame_buffer::attach(), cgv::render::frame_buffer::attach(), bind_as_image(), and enable().
void cgv::render::texture::find_best_format | ( | const context & | ctx, |
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
find the format that matches the one specified in the component format best
Definition at line 190 of file texture.cxx.
References set_component_format().
Referenced by create(), create(), and create_from_buffer().
bool cgv::render::texture::generate_mipmaps | ( | const context & | ctx | ) |
generate mipmaps automatically, only supported if framebuffer objects are supported by the GPU
Definition at line 518 of file texture.cxx.
References cgv::data::data_format::get_nr_dimensions().
Referenced by vr_test::init_frame().
float cgv::render::texture::get_anisotropy | ( | ) | const |
return the currently set anisotropy
Definition at line 133 of file texture.cxx.
CompareFunction cgv::render::texture::get_compare_function | ( | ) | const |
get the texture compare function
Definition at line 179 of file texture.cxx.
bool cgv::render::texture::get_compare_mode | ( | ) | const |
get the texture compare mode and function
Definition at line 166 of file texture.cxx.
TextureFilter cgv::render::texture::get_mag_filter | ( | ) | const |
return the magnification filter
Definition at line 144 of file texture.cxx.
TextureFilter cgv::render::texture::get_min_filter | ( | ) | const |
return the minification filter
Definition at line 128 of file texture.cxx.
|
inline |
float cgv::render::texture::get_priority | ( | ) | const |
return the priority with which texture is kept in GPU memory
Definition at line 155 of file texture.cxx.
int cgv::render::texture::get_tex_unit | ( | ) | const |
return the currently used texture unit and -1 for current
Definition at line 784 of file texture.cxx.
TextureWrap cgv::render::texture::get_wrap_r | ( | ) | const |
return the texture wrap behaviour in r direction
Definition at line 105 of file texture.cxx.
TextureWrap cgv::render::texture::get_wrap_s | ( | ) | const |
return the texture wrap behaviour in s direction
Definition at line 95 of file texture.cxx.
TextureWrap cgv::render::texture::get_wrap_t | ( | ) | const |
return the texture wrap behaviour in t direction
Definition at line 100 of file texture.cxx.
bool cgv::render::texture::is_enabled | ( | ) | const |
check whether textue is enabled
Definition at line 779 of file texture.cxx.
bool cgv::render::texture::mipmaps_created | ( | ) | const |
check whether mipmaps have been created
Definition at line 774 of file texture.cxx.
bool cgv::render::texture::replace | ( | const context & | ctx, |
int | x, | ||
const cgv::data::const_data_view & | data, | ||
int | level = -1 , |
||
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
replace a block within a 1d texture with the given data.
If level is not specified, level 0 is set and if a mipmap has been created before, coarser levels are updated also.
Definition at line 621 of file texture.cxx.
References cgv::data::data_view_base::get_format(), cgv::data::data_format::get_nr_dimensions(), cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
Referenced by create(), vr_test::init_frame(), and replace_from_image().
bool cgv::render::texture::replace | ( | const context & | ctx, |
int | x, | ||
int | y, | ||
const cgv::data::const_data_view & | data, | ||
int | level = -1 , |
||
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
replace a block within a 2d texture with the given data.
If level is not specified, level 0 is set and if a mipmap has been created before, coarser levels are updated also.
Definition at line 637 of file texture.cxx.
References cgv::data::data_view_base::get_format(), cgv::data::data_format::get_nr_dimensions(), cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
bool cgv::render::texture::replace | ( | const context & | ctx, |
int | x, | ||
int | y, | ||
int | z_or_cube_side, | ||
const cgv::data::const_data_view & | data, | ||
int | level = -1 , |
||
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
replace a block within a 3d texture or a side of a cube map with the given data.
If level is not specified, level 0 is set and if a mipmap has been created before, coarser levels are updated also.
Definition at line 654 of file texture.cxx.
References cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
bool cgv::render::texture::replace_from_buffer | ( | const context & | ctx, |
int | x, | ||
int | y, | ||
int | x_buffer, | ||
int | y_buffer, | ||
int | width, | ||
int | height, | ||
int | level = -1 |
||
) |
replace a block within a 2d texture from the current read buffer.
Definition at line 667 of file texture.cxx.
References cgv::data::data_format::get_nr_dimensions(), cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
Referenced by cgv::render::gl::gl_depth_peeler::copy_depth_buffer(), create_from_buffer(), cgv::render::a_buffer::enable(), and cgv::render::gl::gl_transparent_renderer::render_transparent().
bool cgv::render::texture::replace_from_buffer | ( | const context & | ctx, |
int | x, | ||
int | y, | ||
int | z_or_cube_side, | ||
int | x_buffer, | ||
int | y_buffer, | ||
int | width, | ||
int | height, | ||
int | level | ||
) |
replace a block within a 3d texture or a side from a cube map from the current read buffer.
replace a block within a 2d texture from the current read buffer.
Definition at line 682 of file texture.cxx.
References cgv::render::render_component::is_created(), and cgv::render::render_component::last_error.
bool cgv::render::texture::replace_from_image | ( | cgv::data::data_format & | df, |
cgv::data::data_view & | dv, | ||
const context & | ctx, | ||
const std::string & | file_name, | ||
int | x, | ||
int | y, | ||
int | z_or_cube_side, | ||
int | level | ||
) |
same as previous method but use the passed data format and data view to store the content of the image.
Definition at line 706 of file texture.cxx.
References cgv::media::image::image_reader::read_image(), cgv::media::image::image_reader::read_palette(), and replace().
bool cgv::render::texture::replace_from_image | ( | const context & | ctx, |
const std::string & | file_name, | ||
int | x, | ||
int | y, | ||
int | z_or_cube_side, | ||
int | level | ||
) |
replace within a slice of a volume or a side of a cube map from the given image
Definition at line 697 of file texture.cxx.
References replace_from_image().
Referenced by replace_from_image().
|
inline |
set the border color
Definition at line 58 of file texture.h.
References set_border_color().
Referenced by set_border_color().
void cgv::render::texture::set_border_color | ( | float | r, |
float | g, | ||
float | b, | ||
float | a = 1.0f |
||
) |
set the border color
Definition at line 110 of file texture.cxx.
void cgv::render::texture::set_compare_function | ( | CompareFunction | compare_function | ) |
set the texture compare function
Definition at line 172 of file texture.cxx.
Referenced by cgv::render::gl::gl_depth_peeler::init_frame().
void cgv::render::texture::set_compare_mode | ( | bool | use_compare_function | ) |
set the texture compare mode and function
Definition at line 160 of file texture.cxx.
Referenced by cgv::render::gl::gl_depth_peeler::init_frame().
void cgv::render::texture::set_component_format | ( | const component_format & | cf | ) |
change component format and clear internal format
Definition at line 61 of file texture.cxx.
References cgv::data::data_format::set_component_format().
Referenced by find_best_format(), and cgv::render::gl::set_gl_format().
void cgv::render::texture::set_component_format | ( | const std::string & | description | ) |
change component format and clear internal format
Definition at line 69 of file texture.cxx.
References cgv::data::component_format::set_component_format().
bool cgv::render::texture::set_data_format | ( | const std::string & | description | ) |
change the data format and clear internal format
Definition at line 52 of file texture.cxx.
References cgv::data::data_format::set_data_format().
void cgv::render::texture::set_fixed_sample_locations | ( | bool | use | ) |
set whether multi sampling uses fixed sample locations
Definition at line 230 of file texture.cxx.
void cgv::render::texture::set_mag_filter | ( | TextureFilter | _mag_filter | ) |
set the magnification filter
Definition at line 138 of file texture.cxx.
Referenced by cgv::render::a_buffer::a_buffer(), cgv::render::build_render_info(), vr_test::init_frame(), and cgv::render::volume_renderer::volume_renderer().
void cgv::render::texture::set_min_filter | ( | TextureFilter | _min_filter, |
float | _anisotropy = 2.0f |
||
) |
set the minification filters, if minification is set to TF_ANISOTROP, the second floating point parameter specifies the degree of anisotropy
Definition at line 120 of file texture.cxx.
Referenced by cgv::render::a_buffer::a_buffer(), cgv::render::build_render_info(), vr_test::init_frame(), and cgv::render::volume_renderer::volume_renderer().
void cgv::render::texture::set_nr_multi_samples | ( | unsigned | _nr_samples | ) |
set the number of multi samples for textures of type TT_MULTISAMPLE_2D and TT_MULTISAMPLE_2D_ARRAY
Definition at line 225 of file texture.cxx.
void cgv::render::texture::set_priority | ( | float | _priority | ) |
set priority with which texture is kept in GPU memory
Definition at line 149 of file texture.cxx.
void cgv::render::texture::set_wrap_r | ( | TextureWrap | _wrap_r | ) |
set the texture wrap behaviour in r direction
Definition at line 89 of file texture.cxx.
void cgv::render::texture::set_wrap_s | ( | TextureWrap | _wrap_s | ) |
set the texture wrap behaviour in s direction
Definition at line 77 of file texture.cxx.
Referenced by cgv::render::build_render_info(), cgv::render::textured_material::ensure_textures(), and cgv::render::volume_renderer::volume_renderer().
void cgv::render::texture::set_wrap_t | ( | TextureWrap | _wrap_t | ) |
set the texture wrap behaviour in t direction
Definition at line 83 of file texture.cxx.
Referenced by cgv::render::build_render_info(), cgv::render::textured_material::ensure_textures(), and cgv::render::volume_renderer::volume_renderer().
|
inline |
bool cgv::render::texture::write_to_file | ( | context & | ctx, |
const std::string & | file_name, | ||
unsigned int | z_or_cube_side = -1 , |
||
float | depth_map_gamma = 1.0f , |
||
const std::string & | options = "" |
||
) | const |
write the content of the texture to a file. This method needs support for frame buffer objects.
Definition at line 427 of file texture.cxx.
References cgv::render::frame_buffer::attach(), cgv::data::CF_D, cgv::data::CF_RGB, cgv::render::frame_buffer::create(), cgv::render::render_buffer::create(), cgv::data::data_format::data_format(), cgv::render::frame_buffer::disable(), cgv::render::frame_buffer::enable(), cgv::data::data_format::get_height(), cgv::utils::statistics::get_max(), cgv::utils::statistics::get_min(), cgv::data::data_view_impl< D, P >::get_ptr(), cgv::data::component_format::get_standard_component_format(), cgv::data::data_format::get_width(), cgv::render::frame_buffer::is_complete(), cgv::render::render_component::is_created(), cgv::render::frame_buffer::last_error, last_error, cgv::base::base::multi_set(), cgv::render::context::read_frame_buffer(), cgv::data::component_format::set(), cgv::data::data_format::set_height(), cgv::data::data_format::set_width(), cgv::type::info::TI_UINT8, cgv::utils::statistics::update(), and cgv::media::image::image_writer::write_image().
|
mutable |
a string that contains the last error
Definition at line 309 of file context.h.
Referenced by write_to_file().
|
mutableprotected |