1#include <cgv/base/base.h>
2#include "textured_material.h"
11 alpha_test_func = AT_GREATER;
12 alpha_threshold = 0.0f;
18 : media::illum::textured_surface_material(mtl)
20 alpha_test_func = AT_GREATER;
21 alpha_threshold = 0.0f;
36 textures.push_back(0);
37 textures.push_back(&tex);
38 return (
int)textures.size() - 1;
46 textures.push_back(0);
70 alpha_test_func = _alpha_test_func;
71 alpha_threshold = _alpha_threshold;
78 return alpha_test_func;
85 return alpha_threshold;
91 return alpha_test_func;
96 return alpha_threshold;
111 for (
size_t ti = 0; ti < textures.size(); ++ti) {
113 textures[ti]->destruct(ctx);
124 for (
unsigned ti = 0; ti < textures.size(); ++ti) {
126 textures[ti]->enable(ctx, ti);
133 for (
unsigned ti = 0; ti < textures.size(); ++ti) {
135 textures[ti]->disable(ctx);
142 assert(ti < (
int)textures.size());
simple class to hold the material properties of a phong material
std::vector< std::string > image_file_names
vector of image file names
base class for all drawables, which is independent of the used rendering API.
virtual bool make_current() const =0
make the current context current if possible
the texture class encapsulates all functionality independent of the rendering api.
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.
void set_wrap_t(TextureWrap _wrap_t)
set the texture wrap behaviour in t direction
bool destruct(const context &ctx)
destruct the texture and free texture memory and handle
void set_wrap_s(TextureWrap _wrap_s)
set the texture wrap behaviour in s direction
AlphaTestFunc & ref_alpha_test_func()
return reference to currently set alpha test function
texture * get_texture(int texture_index) const
return pointer to ambient texture or 0 if non created
void disable_textures(context &ctx)
disable material textures
virtual ~textured_material()
ensure that textures are destructed
AlphaTestFunc
different test functions for alpha test
float get_alpha_threshold() const
return the currently used alpha threshold used by the comparison alpha test functions
float & ref_alpha_threshold()
return reference to currently used alpha threshold used by the comparison alpha test functions
void set_alpha_test(AlphaTestFunc _alpha_test_func=AT_GREATER, float _alpha_threshold=0.0f)
configure the alpha test that is performed in case alpha values are given in the textures
void destruct_textures(context &ctx)
destruct textures
AlphaTestFunc get_alpha_test_func() const
return the currently set alpha test function
int add_texture_reference(cgv::render::texture &tex)
add a reference to a new texture that is managed outside of this class and return its index
textured_material()
initialize textures
void enable_textures(context &ctx)
enable all textures with their indices as texture unit
bool ensure_textures(context &ctx)
call this to ensure that the textures specified by image files are loaded - typically done in the ini...