diff options
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r-- | src/render/draw.cc | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index f5978f7..068c4dc 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -18,6 +18,7 @@ #include "render/draw.h" #include "render/dust.h" #include "render/gl.h" +#include "render/sky.h" #include "math/functions.h" namespace render @@ -136,6 +137,7 @@ void pass_prepare(float seconds) /* ----- Skybox ---------------------------------------------------- */ +/* void draw_sphere_inside(math::Color const & color, float radius) { gl::scale(radius, radius, radius); @@ -152,6 +154,7 @@ void draw_sphere_inside(math::Color const & color, float radius) } } +*/ void draw_pass_sky() { @@ -164,27 +167,7 @@ void draw_pass_sky() if (!core::localplayer()->zone()->sky().size()) return; - if (!core::localplayer()->zone()->sky_texture()) { - - std::string texture_name("textures/env/"); - texture_name.append(core::localplayer()->zone()->sky()); - core::localplayer()->zone()->set_sky_texture(Textures::load(texture_name)); - - if (!core::localplayer()->zone()->sky_texture()) { - core::localplayer()->zone()->set_sky(""); - return; - } - } - - Textures::bind(core::localplayer()->zone()->sky_texture()); - gl::enable(GL_TEXTURE_2D); - gl::push(); - - gl::translate(Camera::eye()); - draw_sphere_inside(math::Color(), 1016.0f); - - gl::pop(); - gl::disable(GL_TEXTURE_2D); + Sky::draw(core::localplayer()->zone()->sky()); } @@ -702,12 +685,16 @@ void draw_model_fragments(model::Model *model, if (material->flags() & model::Material::Environment) { if (!(material->flags() & model::Material::Texture)) { + /* // use sky as envmap if the material defines no texture + // FIXME broken since skybox 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) { + } else + */ + if (use_texture) { gl::disable(GL_TEXTURE_2D); use_texture = false; } @@ -1239,25 +1226,18 @@ void draw(float seconds) glPolygonMode(GL_FRONT, GL_FILL); } + gl::disable(GL_DEPTH_TEST); + gl::depthmask(GL_FALSE); // disable depth buffer writing + + draw_pass_sky(); // draw the skybox + // set vertex array pointers glInterleavedArrays(GL_T2F_N3F_V3F, 0, core::game()->vertexarray()->ptr()); - /* - // this doesnt work - glTexCoordPointer(2, GL_FLOAT, 6 * sizeof(float), core::game()->vertexarray()->ptr()); - glNormalPointer(GL_FLOAT, 5 * sizeof(float), &core::game()->vertexarray()->ptr()[2]); - glVertexPointer(3, GL_FLOAT, 5 * sizeof(float), &core::game()->vertexarray()->ptr()[5]); - */ - // enable vertex arrays glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); - - gl::disable(GL_DEPTH_TEST); - gl::depthmask(GL_FALSE); // disable depth buffer writing - - draw_pass_sky(); // draw the skysphere gl::depthmask(GL_TRUE); // enable writing to the depth buffer gl::enable(GL_DEPTH_TEST); |