Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-10 22:32:36 +0000
committerStijn Buys <ingar@osirion.org>2009-08-10 22:32:36 +0000
commitbd142a328328cdf0cbfbb59e4e0aa99dd51184b8 (patch)
treec2ed4e832e60b379723ea3f530c5b192bec0da61 /src/render
parentbbd04914749b2e3918796fe331daf649b06163ea (diff)
initial texture support for ase models
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 4392f87..c4c18c3 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -564,8 +564,9 @@ void draw_model_fragments(model::Model *model,
{
// default material, lighted and geometry color
const model::Material *material = 0;
- math::Color color(1.0f, 0.0f, 1.0f); // current drawing color
+ math::Color color(1.0f, 1.0f, 1.0f); // current drawing color
bool use_light = true; // gl::disable(GL_LIGHTING) is set
+ bool use_texture = false; // texturing
bool use_env = false; // environment mapping
//bool use_color_array = true; // glEnableClientState(GL_COLOR_ARRAY) is set
@@ -601,7 +602,7 @@ void draw_model_fragments(model::Model *model,
use_color_array = false;
}*/
- gl::color(model->enginecolor() * thrust);
+ color.assign(model->enginecolor() * thrust);
} else if (material->flags() & model::Material::Tertiary) {
/* if (use_color_array) {
@@ -648,26 +649,55 @@ void draw_model_fragments(model::Model *model,
}
}
+ if (material->flags() & model::Material::Texture) {
+
+ Textures::bind(material->texture());
+
+ if (!use_texture) {
+ gl::enable(GL_TEXTURE_2D);
+ use_texture = true;
+ }
+
+ }
+
if (material->flags() & model::Material::Environment) {
- if (!use_env && core::localplayer()->zone()->sky_texture()) {
- Textures::bind(core::localplayer()->zone()->sky_texture());
+
+ if (!(material->flags() & model::Material::Texture)) {
+ // use sky as envmap if the material defines no texture
+ if (core::localplayer()->zone()->sky_texture()) {
+ Textures::bind(core::localplayer()->zone()->sky_texture());
+ gl::enable(GL_TEXTURE_2D);
+ use_texture = true;
+ } else if (use_texture) {
+ gl::disable(GL_TEXTURE_2D);
+ use_texture = false;
+ }
+ }
+ if (!use_env) {
// 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;
}
}
+ if (!(material->flags() & (model::Material::Texture + model::Material::Environment))) {
+ if (use_texture) {
+ gl::disable(GL_TEXTURE_2D);
+ use_texture = false;
+ }
+ }
+
} else {
// material not found
@@ -681,9 +711,14 @@ void draw_model_fragments(model::Model *model,
// 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_texture) {
+ gl::disable(GL_TEXTURE_2D);
+ use_texture = false;
+ }
+
/* if (!use_color_array) {
glEnableClientState(GL_COLOR_ARRAY);
use_color_array = true;
@@ -707,13 +742,16 @@ void draw_model_fragments(model::Model *model,
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_texture) {
+ gl::disable(GL_TEXTURE_2D);
+ use_texture = false;
+ }
+
/* if (!use_color_array) {
glEnableClientState(GL_COLOR_ARRAY);
}*/