3 #ifndef SCENEVIEW_MATERIAL_RESOURCE_HPP__
4 #define SCENEVIEW_MATERIAL_RESOURCE_HPP__
11 #include <sceneview/shader_resource.hpp>
12 #include <sceneview/geometry_resource.hpp>
13 #include <sceneview/shader_uniform.hpp>
36 typedef std::shared_ptr<MaterialResource> Ptr;
38 typedef std::shared_ptr<QOpenGLTexture> TexturePtr;
40 typedef std::map<QString, TexturePtr> TextureDictionary;
42 typedef std::map<QString, TexturePtr> Textures;
44 const ShaderResource::Ptr& Shader() {
return shader_; }
46 ShaderUniformMap& ShaderParameters() {
return shader_parameters_; }
48 void SetParam(
const QString& name,
int val);
50 void SetParam(
const QString& name,
const std::vector<int>& val);
52 void SetParam(
const QString& name,
float val);
54 void SetParam(
const QString& name,
55 float val1,
float val2);
57 void SetParam(
const QString& name,
58 float val1,
float val2,
float val3);
60 void SetParam(
const QString& name,
61 float val1,
float val2,
float val3,
float val4);
63 void SetParam(
const QString& name,
const std::vector<float>& val);
65 void SetParam(
const QString& name,
const QMatrix4x4& value);
67 void AddTexture(
const QString& name,
const TexturePtr& texture);
69 const TextureDictionary& GetTextures() {
return textures_; }
76 bool TwoSided()
const {
return two_sided_; }
78 void SetDepthWrite(
bool val) { depth_write_ = val; }
80 bool DepthWrite()
const {
return depth_write_; }
82 void SetDepthTest(
bool val) { depth_test_ = val; }
84 bool DepthTest()
const {
return depth_test_; }
86 void SetDepthFunc(GLenum func) { depth_func_ = func; }
88 GLenum DepthFunc()
const {
return depth_func_; }
90 void SetColorWrite(
bool val) { color_write_ = val; }
92 bool ColorWrite()
const {
return color_write_; }
94 void SetPointSize(
float size) { point_size_ = size; }
96 float PointSize()
const {
return point_size_; }
98 void SetLineWidth(
float line_width) { line_width_ = line_width; }
100 float LineWidth()
const {
return line_width_; }
113 bool Blend()
const {
return blend_; }
115 void SetBlendFunc(GLenum sfactor, GLenum dfactor) {
116 blend_sfactor_ = sfactor;
117 blend_dfactor_ = dfactor;
120 void BlendFunc(GLenum* sfactor, GLenum* dfactor) {
121 *sfactor = blend_sfactor_;
122 *dfactor = blend_dfactor_;
126 friend class ResourceManager;
128 MaterialResource(
const QString& name, ShaderResource::Ptr shader);
132 ShaderResource::Ptr shader_;
134 ShaderUniformMap shader_parameters_;
136 bool two_sided_ =
false;
138 bool depth_write_ =
true;
140 bool depth_test_ =
true;
142 GLenum depth_func_ = GL_LESS;
144 bool color_write_ =
true;
146 float point_size_ = 1;
148 float line_width_ = 1;
152 GLenum blend_sfactor_ = GL_ONE;
154 GLenum blend_dfactor_ = GL_ZERO;
156 TextureDictionary textures_;
161 #endif // SCENEVIEW_MATERIAL_RESOURCE_HPP__
Controls the appearance of a Drawable.
Definition: material_resource.hpp:34
void SetTwoSided(bool two_sided)
Sets whether or not to draw back-facing polygons.
void SetBlend(bool value)
Controls GL_BLEND.
Definition: material_resource.hpp:108
bool Blend() const
Retrieve whether GL_BLEND should be enabled or disabled.
Definition: material_resource.hpp:113