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>2012-12-28 22:55:35 +0000
committerStijn Buys <ingar@osirion.org>2012-12-28 22:55:35 +0000
commitf416e6b792e5dda143f60b7a2724db6b3ec33d75 (patch)
tree553ddcaa6c60489904a8db818eff688c0b85a437 /src/render
parentfe96eee5db2acbef1ea0f360b180fd9f8f990444 (diff)
Support for rendering globes with rings,
removed hardcoded 'corona' prefix for corona textures, added support for projectile fire sounds.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc66
-rw-r--r--src/render/draw.h5
-rw-r--r--src/render/render.cc12
-rw-r--r--src/render/renderext.cc9
4 files changed, 86 insertions, 6 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);
}
diff --git a/src/render/draw.h b/src/render/draw.h
index 122d7cd..a3b4d30 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -30,9 +30,12 @@ void reset();
/// draw a sphere
void draw_sphere(const math::Color & color, float radius);
-/// draw a corona
+/// draw globe corona
void draw_globe_corona(const math::Vector3f location, const math::Color & color, const float radius, const size_t corona_id);
+/// draw globe rings
+void draw_globe_rings(const math::Color & color, const size_t rings_id);
+
/// draw mode lights and flares
void draw_model_lights(
model::Model *model, const float scale,
diff --git a/src/render/render.cc b/src/render/render.cc
index 794d777..bf14e7d 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -154,9 +154,13 @@ void unload()
globe->set_texture_id(0);
}
if (globe->corona_id()) {
- render::Textures::unload("textures/corona/" + globe->coronaname());
+ render::Textures::unload("textures/" + globe->coronaname());
globe->set_corona_id(0);
}
+ if (globe->rings_id()) {
+ render::Textures::unload("textures/" + globe->ringsname());
+ globe->set_rings_id(0);
+ }
}
if (ext_render(entity)) {
@@ -182,9 +186,13 @@ void clear()
globe->set_texture_id(0);
}
if (globe->corona_id()) {
- render::Textures::unload("textures/corona/" + globe->coronaname());
+ render::Textures::unload("textures/" + globe->coronaname());
globe->set_corona_id(0);
}
+ if (globe->rings_id()) {
+ render::Textures::unload("textures/" + globe->ringsname());
+ globe->set_rings_id(0);
+ }
}
if (ext_render(entity)) {
diff --git a/src/render/renderext.cc b/src/render/renderext.cc
index 0f781c5..1dc82f8 100644
--- a/src/render/renderext.cc
+++ b/src/render/renderext.cc
@@ -95,11 +95,18 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re
}
if (!globe->corona_id() && globe->coronaname().size()) {
- globe->set_corona_id(Textures::bind("textures/corona/" + globe->coronaname()));
+ globe->set_corona_id(Textures::load("textures/" + globe->coronaname()));
if (!globe->corona_id()) {
globe->set_coronaname("");
}
}
+
+ if (!globe->rings_id() && globe->ringsname().size()) {
+ globe->set_rings_id(Textures::load("textures/" + globe->ringsname()));
+ if (!globe->rings_id()) {
+ globe->set_ringsname("");
+ }
+ }
}
}