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>2010-11-18 13:50:47 +0000
committerStijn Buys <ingar@osirion.org>2010-11-18 13:50:47 +0000
commit847f84e1e3797277407bc34f5acc51b801b2bf29 (patch)
tree781edbf9e6663a4b6a8cfbaf173f43cfd83db62b /src/render
parent445f4a201f205763a2241d87ef81a99b5dd55d26 (diff)
Unified radiant angles conversion into a single math::Axis.assign() method, corrected transformation order.
Removed unnecessary model::LIGHTSCALE constant, light and flare sizes are rescaled according to the global model::SCALE. Added gl::depthfunc, enabled GL_LEQUAL while drawing lights and flares.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc25
-rw-r--r--src/render/gl.cc16
-rw-r--r--src/render/gl.h3
-rw-r--r--src/render/particles.cc5
4 files changed, 34 insertions, 15 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index cb8649f..9ebe2cc 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -875,6 +875,12 @@ void draw_pass_model_fx(float elapsed)
math::Vector3f offset;
math::Color color;
math::Axis flare_axis;
+
+ // FIXME
+ // setting the depth buffer comparison function to less-or-equal
+ // this should prevent z-fighting with model geometry,
+ // but doesn't seem to perform as generally expected
+ gl::depthfunc(GL_LEQUAL);
for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
core::Entity *entity = (*it);
@@ -947,7 +953,8 @@ void draw_pass_model_fx(float elapsed)
color.a = a;
location.assign(entity->location() + (entity->axis() * light->location()) * modelscale);
- light_size = 0.0625f * light->radius() * modelscale;
+
+ light_size = light->radius() * modelscale;
// track OpenGL state changes
if (current_texture != light->texture()) {
@@ -1020,7 +1027,8 @@ void draw_pass_model_fx(float elapsed)
color.a = a;
location.assign(entity->location() + (entity->axis() * flare->location()) * modelscale );
- light_size = 0.0625f * flare->radius() * modelscale;
+
+ light_size = flare->radius() * modelscale;
// track OpenGL state changes
if ((current_cull != flare->cull()) || (current_texture != flare->texture())) {
@@ -1102,6 +1110,9 @@ void draw_pass_model_fx(float elapsed)
}
}
+ // restore the default depth buffer comparison function
+ gl::depthfunc(GL_LESS);
+
gl::disable(GL_TEXTURE_2D);
gl::cullface(GL_BACK);
gl::enable(GL_CULL_FACE);
@@ -1173,7 +1184,7 @@ void draw(float seconds)
// calculate client state
pass_prepare(seconds);
- gl::disable(GL_DEPTH_TEST);
+ gl::disable(GL_DEPTH_TEST); // disable depth testing
gl::depthmask(GL_FALSE); // disable depth buffer writing
glPolygonMode(GL_FRONT, GL_FILL);
@@ -1181,7 +1192,8 @@ void draw(float seconds)
draw_pass_sky(); // draw the skybox
gl::depthmask(GL_TRUE); // enable writing to the depth buffer
- gl::enable(GL_DEPTH_TEST);
+ gl::depthfunc(GL_LESS); // default depth buffer comparison function
+ gl::enable(GL_DEPTH_TEST); // enable depth testing
gl::enable(GL_CULL_FACE); // enable culling
gl::enable(GL_COLOR_MATERIAL); // enable color tracking
@@ -1254,8 +1266,11 @@ void draw(float seconds)
}
// draw entity lights, flares and particles
- if (draw_lights || draw_particles)
+ if (draw_lights || draw_particles) {
+
draw_pass_model_fx(seconds);
+
+ }
// draw entity radius globe
if (r_radius && r_radius->value()) {
diff --git a/src/render/gl.cc b/src/render/gl.cc
index 801c320..fa7c092 100644
--- a/src/render/gl.cc
+++ b/src/render/gl.cc
@@ -59,35 +59,39 @@ void depthmask(GLenum mode)
::glDepthMask(mode);
}
+void depthfunc(GLenum func)
+{
+ ::glDepthFunc(func);
+}
void frontface(GLenum mode)
{
- glFrontFace(mode);
+ ::glFrontFace(mode);
}
void cullface(GLenum mode)
{
- glCullFace(mode);
+ ::glCullFace(mode);
}
void shademodel(GLenum mode)
{
- glShadeModel(mode);
+ ::glShadeModel(mode);
}
void blendfunc(GLenum sfactor, GLenum dfactor)
{
- glBlendFunc(sfactor, dfactor);
+ ::glBlendFunc(sfactor, dfactor);
}
void enable(GLenum cap)
{
- glEnable(cap);
+ ::glEnable(cap);
}
void disable(GLenum cap)
{
- glDisable(cap);
+ ::glDisable(cap);
}
void clear(GLbitfield mask)
diff --git a/src/render/gl.h b/src/render/gl.h
index e6d6f92..fc2237e 100644
--- a/src/render/gl.h
+++ b/src/render/gl.h
@@ -109,6 +109,9 @@ void frontface(GLenum mode);
/// glDepthMask
void depthmask(GLenum mode);
+/// glDepthFunc
+void depthfunc(GLenum func);
+
/// glBlendFunc
void blendfunc(GLenum sfactor, GLenum dfactor);
diff --git a/src/render/particles.cc b/src/render/particles.cc
index 86847c3..7a0094d 100644
--- a/src/render/particles.cc
+++ b/src/render/particles.cc
@@ -188,10 +188,7 @@ ParticleScript *ParticleScript::load(const std::string &label)
std::istringstream str(inifile.value());
if (str >> pitch >> yaw >> roll) {
- script->particlescript_axis.clear();
- script->particlescript_axis.change_pitch(-pitch);
- script->particlescript_axis.change_direction(yaw);
- script->particlescript_axis.change_roll(-roll);
+ script->particlescript_axis.assign(yaw, pitch, roll);
} else {
inifile.unknown_value();
}