diff options
author | Stijn Buys <ingar@osirion.org> | 2008-11-12 19:01:51 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-11-12 19:01:51 +0000 |
commit | 1f0dbeeabdffff096908473168898c5fa63bcff0 (patch) | |
tree | 741f0342ae4b43fe3f907c0e29f9ecd0953d5866 /src | |
parent | dd16796ac3ef352a5ff404373b568dd00ef74936 (diff) |
make the corona act like a flare
Diffstat (limited to 'src')
-rw-r--r-- | src/render/draw.cc | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 96bc632..2975ecb 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -303,40 +303,47 @@ void draw_globe(core::EntityGlobe *globe) gl::translate(location); if(flag_is_set(globe->flags(), core::Entity::Bright)) { + + math::Vector3f v = globe->location() - Camera::eye(); + v.normalize(); + float a = dotproduct(v, Camera::axis().forward()); + if (a > 0.1f) { + // FIXME a corona is actually just a giant flare + if (!globe->render_texture) { + gl::enable(GL_TEXTURE_2D); + } + Textures::bind("bitmaps/fx/corona"); - if (!globe->render_texture) { - gl::enable(GL_TEXTURE_2D); - } - Textures::bind("bitmaps/fx/corona"); + if (globe->state()->distance() <= farplane) { + gl::depthmask(GL_FALSE); + } + math::Color color(globe->color()); + color.a = a - 0.1f; - if (globe->state()->distance() <= farplane) { - gl::depthmask(GL_FALSE); - } - gl::color(globe->color()); - globe->color().a = 1.0f; - gl::enable(GL_BLEND); - - gl::begin(gl::Quads); - glTexCoord2f(0,1); - gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(0,0); - gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(1,0); - gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(1,1); - gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 2.0f); - gl::end(); - - Stats::quads++; - - gl::disable(GL_BLEND); - if (globe->state()->distance() <= farplane) { - gl::depthmask(GL_TRUE); - } - if (!globe->render_texture) { - gl::disable(GL_TEXTURE_2D); + gl::color(color); + gl::enable(GL_BLEND); + + gl::begin(gl::Quads); + glTexCoord2f(0,1); + gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(0,0); + gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(1,0); + gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(1,1); + gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 2.0f); + gl::end(); + + Stats::quads++; + + gl::disable(GL_BLEND); + if (globe->state()->distance() <= farplane) { + gl::depthmask(GL_TRUE); + } + if (!globe->render_texture) { + gl::disable(GL_TEXTURE_2D); + } } - radius *= 0.5f; } |