diff options
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r-- | src/render/draw.cc | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 46d0906..a49b017 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -239,6 +239,7 @@ void draw_globe_corona(const math::Vector3f location, const math::Color & color, if (a > 0.1f) { gl::enable(GL_BLEND); gl::disable(GL_DEPTH_TEST); + gl::depthmask(GL_FALSE); // disable depth buffer writes gl::enable(GL_TEXTURE_2D); Textures::bind(corona_id); @@ -263,11 +264,66 @@ void draw_globe_corona(const math::Vector3f location, const math::Color & color, gl::disable(GL_TEXTURE_2D); gl::enable(GL_DEPTH_TEST); + gl::depthmask(GL_TRUE); // enable depth buffer writes gl::disable(GL_BLEND); } } } +void draw_globe_rings(const math::Color & color, const size_t rings_id) +{ + gl::color(color); + + gl::enable(GL_BLEND); + //gl::disable(GL_CULL_FACE); + gl::depthmask(GL_FALSE); // disable depth buffer writes + + Textures::bind(rings_id); + + gl::begin(gl::Quads); + + // top + gl::normal(0.0f, 0.0f, 1.0f); + gl::texcoord(0, 0); + gl::vertex(-2.0f, -2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, 1.0f); + gl::texcoord(1, 0); + gl::vertex(2.0f, -2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, 1.0f); + gl::texcoord(1, 1); + gl::vertex(2.0f, 2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, 1.0f); + gl::texcoord(0, 1); + gl::vertex(-2.0f, 2.0f, 0.0f); + + //bottom + gl::normal(0.0f, 0.0f, -1.0f); + gl::texcoord(0, 1); + gl::vertex(-2.0f, 2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, -1.0f); + gl::texcoord(1, 1); + gl::vertex(2.0f, 2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, -1.0f); + gl::texcoord(1, 0); + gl::vertex(2.0f, -2.0f, 0.0f); + + gl::normal(0.0f, 0.0f, -1.0f); + gl::texcoord(0, 0); + gl::vertex(-2.0f, -2.0f, 0.0f); + + gl::end(); + + gl::depthmask(GL_TRUE); // enable depth buffer writes + + //gl::enable(GL_CULL_FACE); + gl::disable(GL_BLEND); +} + void draw_pass_globes() { // FIXME is this ever reset ? @@ -311,17 +367,23 @@ void draw_pass_globes() } gl::multmatrix(globe->axis()); - if (globe->rotationspeed()) { float angle = math::degrees360f(core::application()->time() * globe->rotationspeed()); gl::rotate(angle, math::Vector3f::Zaxis()); } draw_sphere(globe->color(), radius); + + if (globe->rings_id()) { + if (!globe->texture_id()) { + gl::enable(GL_TEXTURE_2D); + } + draw_globe_rings(globe->color(), globe->rings_id()); + } gl::pop(); - if (globe->texture_id()) { + if (globe->texture_id() || globe->rings_id()) { gl::disable(GL_TEXTURE_2D); } |