Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-10-06 15:21:15 +0000
committerStijn Buys <ingar@osirion.org>2010-10-06 15:21:15 +0000
commit36509ea1a476b30f17b3436edd7f524861257389 (patch)
tree6648e122d9d1ee7e4bb36430cd1aab3cf1129fda /src
parent64a2a6d71023ab382c996ccdb8e403660fa19916 (diff)
removed skydome support, corrected skybox edge issue
Diffstat (limited to 'src')
-rw-r--r--src/model/vertexarray.cc26
-rw-r--r--src/render/draw.cc35
-rw-r--r--src/render/sky.cc41
-rw-r--r--src/render/sky.h2
-rw-r--r--src/render/textures.cc7
5 files changed, 40 insertions, 71 deletions
diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc
index 67a13aa..ee311ac 100644
--- a/src/model/vertexarray.cc
+++ b/src/model/vertexarray.cc
@@ -98,32 +98,6 @@ void VertexArray::add_sphere()
quad_count--;
}
-
- // add inside-out sphere
- for (int j = 0; j < (SPHERESEGMENTS - 1) / 2; j++) {
-
- float r = sintable[j];
- float r1 = sintable[j+1];
-
-
- for (int i = SPHERESEGMENTS - 1 ; i >= 0; i--) {
- v = math::Vector3f(r * costable[i], r * sintable[i], costable[j]);
- n = v;
- n.normalize();
- texx = 1 - (float)i / (float)(SPHERESEGMENTS - 1);
- texy = -costable[j] / 2 + 0.5f;
- add_vertex(v, n, texx, texy);
-
- v = math::Vector3f(r1 * costable[i], r1 * sintable[i], costable[j+1]);
- n = v;
- n.normalize();
- texx = 1 - (float)i / (float)(SPHERESEGMENTS - 1);
- texy = -costable[j+1] / 2 + 0.5f;
- add_vertex(v, n, texx, texy);
- }
-
- }
-
delete[] sintable;
delete[] costable;
}
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 068c4dc..d54387a 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -137,25 +137,6 @@ void pass_prepare(float seconds)
/* ----- Skybox ---------------------------------------------------- */
-/*
-void draw_sphere_inside(math::Color const & color, float radius)
-{
- gl::scale(radius, radius, radius);
- gl::color(color);
-
- size_t index = (model::SPHERESEGMENTS) * (model::SPHERESEGMENTS - 1);
- size_t count = (model::SPHERESEGMENTS) * 2;
-
- // draw body
- for (int j = 0; j < (model::SPHERESEGMENTS - 1) / 2; j++) {
- glDrawArrays(gl::QuadStrip, index, count);
- index += count;
- Stats::quads += count / 2 - 1;
- }
-
-}
-*/
-
void draw_pass_sky()
{
if (!(r_sky && r_sky->value()))
@@ -167,7 +148,7 @@ void draw_pass_sky()
if (!core::localplayer()->zone()->sky().size())
return;
- Sky::draw(core::localplayer()->zone()->sky());
+ Sky::draw(core::localplayer()->zone()->sky(), (r_wireframe && r_wireframe->value()));
}
@@ -1219,17 +1200,17 @@ void draw(float seconds)
// calculate client state
pass_prepare(seconds);
- // enable wireframe mode if requested
- if (r_wireframe && r_wireframe->value()) {
- glPolygonMode(GL_FRONT, GL_LINE);
- } else {
- glPolygonMode(GL_FRONT, GL_FILL);
- }
-
gl::disable(GL_DEPTH_TEST);
gl::depthmask(GL_FALSE); // disable depth buffer writing
+ glPolygonMode(GL_FRONT, GL_FILL);
+
draw_pass_sky(); // draw the skybox
+
+ // enable wireframe mode if requested
+ if (r_wireframe && r_wireframe->value()) {
+ glPolygonMode(GL_FRONT, GL_LINE);
+ }
// set vertex array pointers
glInterleavedArrays(GL_T2F_N3F_V3F, 0, core::game()->vertexarray()->ptr());
diff --git a/src/render/sky.cc b/src/render/sky.cc
index e40c4be..1b914a6 100644
--- a/src/render/sky.cc
+++ b/src/render/sky.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "render/render.h"
#include "render/camera.h"
#include "render/sky.h"
#include "render/textures.h"
@@ -20,7 +21,7 @@ size_t Sky::sky_texture_back = 0;
std::string Sky::sky_name;
-void Sky::draw(const std::string & name)
+void Sky::draw(const std::string & name, const float wireframe)
{
if (sky_name.compare(name) != 0) {
unload();
@@ -31,28 +32,36 @@ void Sky::draw(const std::string & name)
if (name.size()) {
const std::string basename("textures/sky/" + name);
- sky_texture_up = Textures::load(basename + "_up");
- sky_texture_down = Textures::load(basename + "_down");
- sky_texture_left = Textures::load(basename + "_left");
- sky_texture_right = Textures::load(basename + "_right");
- sky_texture_front = Textures::load(basename + "_front");
- sky_texture_back = Textures::load(basename + "_back");
+ sky_texture_up = Textures::load(basename + "_up", false);
+ sky_texture_down = Textures::load(basename + "_down", false);
+ sky_texture_left = Textures::load(basename + "_left", false);
+ sky_texture_right = Textures::load(basename + "_right", false);
+ sky_texture_front = Textures::load(basename + "_front", false);
+ sky_texture_back = Textures::load(basename + "_back", false);
}
sky_name.assign(name);
}
/*
- * NOTE
- * for quake3 skyboxes: the _left texture is actually the right side of the skybox
+ * NOTE:
+ * to use quake3 skyboxes:
+ * switch left and right images
+ * rotate top image 90 degrees clockwise
+ * rotate bottom image 90 degrees counter-clockwise
+ *
*/
+
+ const gl::Primitive primitive = (wireframe ? gl::LineLoop : gl::Quads);
+
gl::push();
gl::translate(Camera::eye());
+
gl::enable(GL_TEXTURE_2D);
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
// front
Textures::bind(sky_texture_front);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(1, 1, 1);
gl::texcoord(1, 0); gl::vertex(1, -1, 1);
gl::texcoord(1, 1); gl::vertex(1, -1, -1);
@@ -61,7 +70,7 @@ void Sky::draw(const std::string & name)
// right
Textures::bind(sky_texture_right);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(1, -1, 1);
gl::texcoord(1, 0); gl::vertex(-1, -1, 1);
gl::texcoord(1, 1); gl::vertex(-1, -1, -1);
@@ -70,7 +79,7 @@ void Sky::draw(const std::string & name)
// back
Textures::bind(sky_texture_back);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(-1, -1, 1);
gl::texcoord(1, 0); gl::vertex(-1, 1, 1);
gl::texcoord(1, 1); gl::vertex(-1, 1, -1);
@@ -79,7 +88,7 @@ void Sky::draw(const std::string & name)
// left
Textures::bind(sky_texture_left);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(-1, 1, 1);
gl::texcoord(1, 0); gl::vertex(1, 1, 1);
gl::texcoord(1, 1); gl::vertex(1, 1, -1);
@@ -88,7 +97,7 @@ void Sky::draw(const std::string & name)
// up
Textures::bind(sky_texture_up);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(-1, 1, 1);
gl::texcoord(1, 0); gl::vertex(-1, -1, 1);
gl::texcoord(1, 1); gl::vertex(1, -1, 1);
@@ -97,7 +106,7 @@ void Sky::draw(const std::string & name)
// down
Textures::bind(sky_texture_down);
- gl::begin(gl::Quads);
+ gl::begin(primitive);
gl::texcoord(0, 0); gl::vertex(1, 1, -1);
gl::texcoord(1, 0); gl::vertex(1, -1, -1);
gl::texcoord(1, 1); gl::vertex(-1, -1, -1);
@@ -107,6 +116,8 @@ void Sky::draw(const std::string & name)
gl::pop();
gl::disable(GL_TEXTURE_2D);
+
+ Stats::quads += 6;
}
void Sky::unload()
diff --git a/src/render/sky.h b/src/render/sky.h
index d922d75..9c41ee0 100644
--- a/src/render/sky.h
+++ b/src/render/sky.h
@@ -17,7 +17,7 @@ public:
static void unload();
- static void draw(const std::string & name);
+ static void draw(const std::string & name, const float wireframe = false);
private:
diff --git a/src/render/textures.cc b/src/render/textures.cc
index 25521e9..e252f2d 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -194,14 +194,17 @@ size_t Textures::load(const std::string &name, const bool filter)
}
// enable texture wrapping
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
} else {
// scaling functions
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// no mipmaps, base level only
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);