Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc36
-rw-r--r--src/render/render.cc20
-rw-r--r--src/render/renderext.cc17
3 files changed, 39 insertions, 34 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 4cf5571..79daffd 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -202,9 +202,9 @@ void draw_globe(const core::EntityGlobe* globe)
gl::disable(GL_LIGHT0);
}
- if (globe->render_texture) {
+ if (globe->texture_id()) {
// textured globe
- Textures::bind(globe->render_texture);
+ Textures::bind(globe->texture_id());
gl::enable(GL_TEXTURE_2D);
}
@@ -238,29 +238,23 @@ void draw_globe(const core::EntityGlobe* globe)
draw_sphere(globe->color(), radius);
gl::pop();
-
- if (globe->flag_is_set(core::Entity::Bright)) {
+ if (globe->flag_is_set(core::Entity::Bright) && globe->corona_id()) {
math::Vector3f v = globe->location() - Camera::eye();
v.normalize();
float a = dotproduct(v, Camera::axis().forward());
if (a > 0.1f) {
- // FIXME a corona is actually just a giant flare
- if (!globe->render_texture) {
- gl::enable(GL_TEXTURE_2D);
- }
- Textures::bind("textures/fx/corona");
- /*
- if (ext_render(globe)->distance() <= farplane) {
- gl::depthmask(GL_FALSE);
- }*/
+ gl::enable(GL_BLEND);
gl::disable(GL_DEPTH_TEST);
+ gl::enable(GL_TEXTURE_2D);
+
+ Textures::bind(globe->corona_id());
math::Color color(globe->color());
color.a = a - 0.1f;
gl::color(color);
- gl::enable(GL_BLEND);
+
gl::begin(gl::Quads);
glTexCoord2f(0, 1);
@@ -275,16 +269,10 @@ void draw_globe(const core::EntityGlobe* globe)
Stats::quads++;
- gl::disable(GL_BLEND);
- /*
- if (ext_render(globe)->distance() <= farplane) {
- gl::depthmask(GL_TRUE);
- }*/
- if (!globe->render_texture) {
- gl::disable(GL_TEXTURE_2D);
- }
-
+
+ gl::disable(GL_TEXTURE_2D);
gl::enable(GL_DEPTH_TEST);
+ gl::disable(GL_BLEND);
}
}
@@ -305,7 +293,7 @@ void draw_globe(const core::EntityGlobe* globe)
gl::enable(GL_LIGHT0);
}
- if (globe->render_texture) {
+ if (globe->texture_id()) {
gl::disable(GL_TEXTURE_2D);
}
}
diff --git a/src/render/render.cc b/src/render/render.cc
index 7776ef2..33dcb0c 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -172,9 +172,14 @@ void unload()
if (entity->type() == core::Entity::Globe) {
core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
- if (globe->render_texture) {
- render::Textures::unload(globe->render_texture);
- globe->render_texture = 0;
+
+ if (globe->texture_id()) {
+ render::Textures::unload("textures/" + globe->texturename());
+ globe->set_texture_id(0);
+ }
+ if (globe->corona_id()) {
+ render::Textures::unload("textures/corona/" + globe->coronaname());
+ globe->set_corona_id(0);
}
}
@@ -199,7 +204,14 @@ void clear()
if (entity->type() == core::Entity::Globe) {
core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
- globe->render_texture = 0;
+ if (globe->texture_id()) {
+ render::Textures::unload("textures/" + globe->texturename());
+ globe->set_texture_id(0);
+ }
+ if (globe->corona_id()) {
+ render::Textures::unload("textures/corona/" + globe->coronaname());
+ globe->set_corona_id(0);
+ }
}
if (ext_render(entity)) {
diff --git a/src/render/renderext.cc b/src/render/renderext.cc
index 049b3de..8ec31bf 100644
--- a/src/render/renderext.cc
+++ b/src/render/renderext.cc
@@ -82,12 +82,17 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re
core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
// load globe textures
- if (!globe->render_texture && globe->texture().size()) {
- std::stringstream texname;
- texname << "textures/" << globe->texture();
- globe->render_texture = Textures::load(texname.str());
- if (!globe->render_texture)
- globe->entity_texture.clear();
+ if (!globe->texture_id() && globe->texturename().size()) {
+ globe->set_texture_id(Textures::load("textures/" + globe->texturename()));
+ if (!globe->texture_id())
+ globe->set_texturename("");
+ }
+
+ if (!globe->corona_id() && globe->coronaname().size()) {
+ globe->set_corona_id(Textures::bind("textures/corona/" + globe->coronaname()));
+ if (!globe->corona_id()) {
+ globe->set_coronaname("");
+ }
}
}
}