Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvan Goers <mega@osirion.org>2014-09-21 03:30:48 +0000
committerEvan Goers <mega@osirion.org>2014-09-21 03:30:48 +0000
commit7550a2e19516d7924bcd89356f3f1b0402180e2f (patch)
tree9554b0e74737d431640521c47aba68c2e26c98a6 /src
parent62a0cbd0f2f9b59d078d3feecf1296c7066163a8 (diff)
Added shininess setting for shaders.
Diffstat (limited to 'src')
-rw-r--r--src/model/layer.cc6
-rw-r--r--src/model/layer.h18
-rw-r--r--src/model/material.cc6
-rw-r--r--src/render/gl.cc5
-rw-r--r--src/render/gl.h3
-rw-r--r--src/render/state.cc8
6 files changed, 39 insertions, 7 deletions
diff --git a/src/model/layer.cc b/src/model/layer.cc
index 4ef7fbf..014795c 100644
--- a/src/model/layer.cc
+++ b/src/model/layer.cc
@@ -14,6 +14,7 @@ Layer::Layer() :
layer_rgbgen(RGBGenIdentity),
layer_color(1.0f),
layer_color_specular(1.0f),
+ layer_shininess(32),
layer_texmap(TexMapNone),
layer_texture_name(),
layer_texture_id(0),
@@ -47,6 +48,11 @@ void Layer::set_specular(const math::Color & specular)
layer_color_specular.assign(specular);
}
+void Layer::set_shininess(const math::Color & shininess)
+{
+ layer_shininess.assign(shininess);
+}
+
void Layer::set_texmap(const TexMap texmap)
{
layer_texmap = texmap;
diff --git a/src/model/layer.h b/src/model/layer.h
index d6af529..6bf75ca 100644
--- a/src/model/layer.h
+++ b/src/model/layer.h
@@ -104,6 +104,15 @@ public:
}
/**
+ * @brief layer shininess
+ * The shininess value is used to control the GL_SHININESS of the layer.
+ * */
+ inline const math::Color & shininess() const
+ {
+ return layer_shininess;
+ }
+
+ /**
* @brief layer texture map
*/
const TexMap texmap() const
@@ -169,6 +178,12 @@ public:
* This value is used in lighting calculations
* */
void set_specular(const math::Color & specular);
+
+ /**
+ * @brief set layer specular color
+ * This value is used in lighting calculations
+ * */
+ void set_shininess(const math::Color & shininess);
/**
* @brief set the texture map type
@@ -210,7 +225,8 @@ private:
math::Vector2f layer_size;
RGBGen layer_rgbgen;
math::Color layer_color;
- math::Color layer_color_specular;
+ math::Color layer_color_specular;
+ math::Color layer_shininess;
TexMap layer_texmap;
std::string layer_texture_name;
size_t layer_texture_id;
diff --git a/src/model/material.cc b/src/model/material.cc
index d4accc8..3d67cad 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -184,7 +184,7 @@ void Material::load_shaderfile(const std::string &shadername)
unsigned int linenumber = 0;
char line[1024];
unsigned int count = 0;
- float r, g, b, a;
+ float r, g, b, a, shine;
Material *material = 0;
Layer *layer = 0;
@@ -309,6 +309,10 @@ void Material::load_shaderfile(const std::string &shadername)
}
layer->set_specular(math::Color(r, g, b, a));
}
+ } else if (firstword.compare("shininess") == 0) {
+ if (linestream >> shine) {
+ layer->set_shininess(shine);
+ }
} else if (firstword.compare("engine") == 0) {
layer->set_rgbgen(Layer::RGBGenEngine);
} else if (firstword.compare("entity") == 0) {
diff --git a/src/render/gl.cc b/src/render/gl.cc
index 932fe34..7b05da7 100644
--- a/src/render/gl.cc
+++ b/src/render/gl.cc
@@ -270,6 +270,11 @@ void specular(Color const & specular)
glMaterialfv(GL_FRONT, GL_SPECULAR, specular.ptr());
}
+void shininess(Color const & shine)
+{
+ glMaterialfv(GL_FRONT, GL_SHININESS, shine.ptr());
+}
+
void matrixmode(GLenum mode)
{
glMatrixMode(mode);
diff --git a/src/render/gl.h b/src/render/gl.h
index c5da4db..cf9e89d 100644
--- a/src/render/gl.h
+++ b/src/render/gl.h
@@ -257,6 +257,9 @@ void color(const float r, const float g, const float b, const float a = 1.0f);
/// specify the specular reflectivity color
void specular(math::Color const & specular);
+/// specify the shininess
+void shininess(math::Color const & shine);
+
/// Push the current transformation matrix to the stack
void push();
diff --git a/src/render/state.cc b/src/render/state.cc
index 6f791b3..8ada29c 100644
--- a/src/render/state.cc
+++ b/src/render/state.cc
@@ -234,7 +234,8 @@ void State::use_material_layer(const model::Material * material, const model::La
}
math::Color color(layer->color());
- math::Color specular(layer->color());
+ math::Color specular(layer->specular());
+ math::Color shine(layer->shininess());
// apply color generation rules
switch (layer->rgbgen()) {
@@ -283,6 +284,7 @@ void State::use_material_layer(const model::Material * material, const model::La
gl::color(color);
gl::specular(specular);
+ gl::shininess(shine);
// lighted or fullbright
if (state_power && layer->fullbright()) {
@@ -328,7 +330,6 @@ void State::use_material_layer(const model::Material * material, const model::La
} else {
color.assign(0.0f, 0.0f, 0.0f);
}
- gl::material(GL_FRONT, GL_SHININESS, 4);
}
@@ -361,9 +362,6 @@ void State::reset()
gl::disable(GL_TEXTURE_CUBE_MAP);
gl::disable(GL_TEXTURE_2D);
- // default specular shininess setting
- gl::material(GL_FRONT, GL_SHININESS, 8);
-
gl::color(math::Color(1.0f));
gl::specular(math::Color(0.0f));
}