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-01-13 19:29:54 +0000
committerStijn Buys <ingar@osirion.org>2009-01-13 19:29:54 +0000
commit5992c46fc62db1bdf038b5b7be0e94dd10183e77 (patch)
tree91b513b038a4e8c2590d02bc7aeea382f998bb43 /src/render/draw.cc
parent9caf289046ed2639f1935fb1c87133af4f7f6cac (diff)
adds 'cull' option to fx_flare and fx_particles
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc66
1 files changed, 60 insertions, 6 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index fbf5058..3806672 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -744,9 +744,14 @@ void draw_pass_model_fx(float elapsed)
math::Axis flare_axis;
- size_t current_texture = Textures::bind("textures/fx/flare00");
+ // disable culling by default
+ gl::disable(GL_CULL_FACE);
+ model::Cull current_cull = model::CullNone;
+ // default light texture
+ size_t current_texture = Textures::bind("textures/fx/flare00");
gl::enable(GL_TEXTURE_2D);
+
gl::begin(gl::Quads);
for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
@@ -775,6 +780,7 @@ void draw_pass_model_fx(float elapsed)
location.assign(entity->location() + (entity->axis() * light->location()));
light_size = 0.0625 * light->radius();
+ // track stat changes
if (current_texture != light->texture()) {
gl::end();
current_texture = Textures::bind(light->texture());
@@ -826,9 +832,32 @@ void draw_pass_model_fx(float elapsed)
location.assign(entity->location() + (entity->axis() * flare->location()));
light_size = 0.0625 * flare->radius();
- if (current_texture != flare->texture()) {
+ if ((current_cull != flare->cull()) || (current_texture != flare->texture())) {
gl::end();
- current_texture = Textures::bind(flare->texture());
+
+ if (current_texture != flare->texture()) {
+ current_texture = Textures::bind(flare->texture());
+ }
+
+ if (current_cull != flare->cull()) {
+ if (flare->cull() == model::CullNone) {
+ gl::disable(GL_CULL_FACE);
+ current_cull = model::CullNone;
+ } else {
+ if (current_cull == model::CullNone) {
+ gl::enable(GL_CULL_FACE);
+ }
+
+ if (flare->cull() == model::CullBack) {
+ gl::cullface(GL_BACK);
+ current_cull = model::CullBack;
+ } else {
+ gl::cullface(GL_FRONT);
+ current_cull = model::CullFront;
+ }
+ }
+ }
+
gl::begin(gl::Quads);
}
@@ -870,23 +899,48 @@ void draw_pass_model_fx(float elapsed)
// draw particle systems
if (r_particles->value() && ext_render(entity)->particles().size()) {
gl::end();
- gl::disable(GL_CULL_FACE);
-
+
for (RenderExt::ParticleSystems::iterator it = ext_render(entity)->particles().begin(); it != ext_render(entity)->particles().end(); it++) {
ParticleSystem *particlesystem = (*it);
+
+ if (current_cull != particlesystem->cull()) {
+ if (particlesystem->cull() == model::CullNone) {
+ gl::disable(GL_CULL_FACE);
+ current_cull = model::CullNone;
+ } else {
+ if (current_cull == model::CullNone) {
+ gl::enable(GL_CULL_FACE);
+ }
+
+ if (particlesystem->cull() == model::CullBack) {
+ gl::cullface(GL_BACK);
+ current_cull = model::CullBack;
+ } else {
+ gl::cullface(GL_FRONT);
+ current_cull = model::CullFront;
+ }
+ }
+ }
+
particlesystem->draw(elapsed);
}
- gl::enable(GL_CULL_FACE);
current_texture = Textures::bind("textures/fx/flare00");
gl::begin(gl::Quads);
}
+
+ if (current_cull != model::CullNone) {
+ gl::disable(GL_CULL_FACE);
+ current_cull = model::CullNone;
+ }
}
}
gl::end();
gl::disable(GL_TEXTURE_2D);
+ gl::cullface(GL_BACK);
+ gl::enable(GL_CULL_FACE);
}