Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 5b3127b..c559353 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -544,8 +544,14 @@ void draw_model_fragments(model::Model *model,
// default material, lighted and geometry color
const model::Material *material = 0;
bool use_light = true; // gl::disable(GL_LIGHTING) is set
+ bool use_env = false; // environment mapping
//bool use_color_array = true; // glEnableClientState(GL_COLOR_ARRAY) is set
+ // TODO this should probably be initialized somewhere else
+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+
+
for (model::Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) {
model::FragmentGroup *group = (*git);
@@ -624,12 +630,43 @@ void draw_model_fragments(model::Model *model,
use_light = true;
}
}
+
+ if (material->flags() & model::Material::Environment) {
+ if (!use_env) {
+ Textures::bind(core::localplayer()->zone()->sky_texture());
+
+ // enable env mapping
+ gl::enable(GL_TEXTURE_2D);
+ gl::enable(GL_TEXTURE_GEN_S);
+ gl::enable(GL_TEXTURE_GEN_T);
+ use_env = true;
+ }
+ } else {
+ if (use_env) {
+ // disable env mapping
+ gl::disable(GL_TEXTURE_GEN_S);
+ gl::disable(GL_TEXTURE_GEN_T);
+ gl::disable(GL_TEXTURE_2D);
+ use_env = false;
+ }
+ }
+
} else {
// material not found
+
if (use_light) {
+ // disable lighting
gl::disable(GL_LIGHTING);
use_light = false;
}
+
+ if (use_env) {
+ // disable env mapping
+ gl::disable(GL_TEXTURE_GEN_S);
+ gl::disable(GL_TEXTURE_GEN_T);
+ gl::disable(GL_TEXTURE_2D);
+ use_env = false;
+ }
/* if (!use_color_array) {
glEnableClientState(GL_COLOR_ARRAY);
use_color_array = true;
@@ -650,6 +687,15 @@ void draw_model_fragments(model::Model *model,
gl::enable(GL_LIGHTING);
}
+ if (use_env) {
+ // disable env mapping
+ gl::disable(GL_TEXTURE_2D);
+ gl::disable(GL_TEXTURE_GEN_S);
+ gl::disable(GL_TEXTURE_GEN_T);
+
+ use_env = false;
+ }
+
/* if (!use_color_array) {
glEnableClientState(GL_COLOR_ARRAY);
}*/