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.cc58
-rw-r--r--src/render/render.cc12
-rw-r--r--src/render/render.h5
3 files changed, 65 insertions, 10 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 1091d8c..6aafcca 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -66,6 +66,25 @@ void draw_sphere(math::Color const & color, float radius)
//gl::pop();
}
+void draw_sphere_inside(math::Color const & color, float radius)
+{
+ //gl::push();
+ 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;
+ }
+
+ //gl::pop();
+}
+
void draw_entity_sphere(core::Entity *entity)
{
if ((entity->type() == core::Entity::Globe) && !flag_is_set(entity->flags(), core::Entity::Bright)) {
@@ -393,6 +412,25 @@ void pass_prepare(float seconds)
}
}
+/* Draw skybox */
+void draw_pass_skybox()
+{
+
+ if (!(r_sky && r_sky->value()))
+ return;
+
+ size_t flare_texture = Textures::load("textures/env/sky");
+ Textures::bind(flare_texture);
+
+ gl::enable(GL_TEXTURE_2D);
+ gl::push();
+
+ draw_sphere_inside(math::Color(), 512);
+
+ gl::pop();
+ gl::disable(GL_TEXTURE_2D);
+}
+
/* Draw entities without model */
void draw_pass_default()
{
@@ -692,6 +730,9 @@ void draw_pass_model_corona()
void draw_pass_spacegrid()
{
+ if (!(r_grid && r_grid->value()))
+ return;
+
int gridsize = 32;
float s = 1.0f / gridsize;
float z = -4.0f;
@@ -741,14 +782,8 @@ void draw(float seconds)
Camera::draw(seconds); // draw the current camera transformation
pass_prepare(seconds);
-
- gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
- gl::enable(GL_CULL_FACE); // enable culling
- gl::enable(GL_COLOR_MATERIAL); // enable color tracking
- gl::enable(GL_LIGHTING);
- gl::disable(GL_BLEND); // disbable alpha blending for world polys
- gl::disable(GL_RESCALE_NORMAL);
+ // enable vertex arrays
glVertexPointer(3, GL_FLOAT, 0, vertexarray->vertex());
glNormalPointer(GL_FLOAT, 0, vertexarray->normal());
glColorPointer(3, GL_FLOAT, 0, vertexarray->color());
@@ -759,6 +794,15 @@ void draw(float seconds)
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ draw_pass_skybox(); // draw the skybox
+
+ gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
+ gl::enable(GL_CULL_FACE); // enable culling
+ gl::enable(GL_COLOR_MATERIAL); // enable color tracking
+ gl::enable(GL_LIGHTING);
+ gl::disable(GL_BLEND); // disbable alpha blending for world polys
+ gl::disable(GL_RESCALE_NORMAL);
+
if (r_wireframe && r_wireframe->value()) {
glPolygonMode(GL_FRONT, GL_LINE);
} else {
diff --git a/src/render/render.cc b/src/render/render.cc
index dac0972..ea70dbf 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -23,10 +23,12 @@ namespace render {
GLuint textures[32];
-core::Cvar *r_radius = 0;
-core::Cvar *r_wireframe = 0;
core::Cvar *r_arraysize = 0;
core::Cvar *r_bbox = 0;
+core::Cvar *r_grid = 0;
+core::Cvar *r_radius = 0;
+core::Cvar *r_sky = 0;
+core::Cvar *r_wireframe = 0;
using model::VertexArray;
@@ -82,9 +84,15 @@ void init()
r_wireframe = core::Cvar::get("r_wireframe", "0", core::Cvar::Archive);
r_wireframe->set_info("[bool] render wireframe");
+ r_grid = core::Cvar::get("r_grid", "1", core::Cvar::Archive);
+ r_grid->set_info("[bool] render the space grid");
+
r_bbox = core::Cvar::get("r_bbox", "0", core::Cvar::Archive);
r_bbox->set_info("[bool] render model bounding box");
+ r_sky = core::Cvar::get("r_sky", "1", core::Cvar::Archive);
+ r_sky->set_info("[bool] render the sky globe");
+
Camera::init();
Textures::init();
diff --git a/src/render/render.h b/src/render/render.h
index ebecf7f..2a8952e 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -24,10 +24,13 @@ namespace render {
/// shutdown the render subsystem
void shutdown();
+ extern core::Cvar *r_arraysize;
extern core::Cvar *r_bbox;
+ extern core::Cvar *r_grid;
extern core::Cvar *r_radius;
+ extern core::Cvar *r_sky;
extern core::Cvar *r_wireframe;
- extern core::Cvar *r_arraysize;
+
extern model::VertexArray *vertexarray;
}