Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/draw.cc')
-rw-r--r--src/client/draw.cc38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/client/draw.cc b/src/client/draw.cc
index 1ea315b..87be92c 100644
--- a/src/client/draw.cc
+++ b/src/client/draw.cc
@@ -139,17 +139,22 @@ void draw_ship(core::EntityControlable *entity)
// draw an entity of entity_type core::Entity::Default
void draw_entity_default(core::Entity *entity)
{
- render::Model *model = 0;
+ using namespace render;
+
+ Model *model = 0;
if (entity->modelname().size())
- model = render::Model::get(entity->modelname());
+ model = Model::get(entity->modelname());
- render::gl::push();
- render::gl::translate(entity->location());
- render::gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
+ gl::push();
+ gl::translate(entity->location());
+ gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
if (model) {
model->draw(entity, camera::eye);
} else {
+ gl::disable(GL_LIGHTING);
+ gl::disable(GL_LIGHT0);
+
switch(entity->shape()) {
case core::Entity::Sphere:
draw_entity_sphere(entity);
@@ -165,9 +170,12 @@ void draw_entity_default(core::Entity *entity)
draw_entity_cube(entity);
break;
}
+
+ gl::enable(GL_LIGHTING);
+ gl::enable(GL_LIGHT0); // disable camera light
}
- render::gl::pop();
+ gl::pop();
}
// draw an entity of entity_type core::Entity::Controlable
@@ -205,6 +213,8 @@ void draw_spacegrid()
float dy = camera::target.y - floorf(camera::target.y);
color(0,0, 1.0f);
+ normal(0, 0, 1.0f);
+
begin(Lines);
for (int i=-gridsize; i <= gridsize; i++) {
color(0,0, 0, 0);
@@ -235,6 +245,14 @@ void draw_world(float seconds)
// draw entities
using namespace render;
+
+ 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::enable(GL_LIGHT0); // enable camera light
+ //gl::enable(GL_NORMALIZE);
+
std::map<unsigned int, core::Entity *>::iterator it;
for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
switch ((*it).second->type()) {
@@ -249,8 +267,16 @@ void draw_world(float seconds)
}
}
+ gl::disable(GL_CULL_FACE); // disable culling
+ gl::disable(GL_COLOR_MATERIAL); // disable color tracking
+ gl::disable(GL_LIGHTING);
+ gl::disable(GL_LIGHT0); // disable camera light
+ //gl::disable(GL_NORMALIZE);
+
// draw the background grid
draw_spacegrid();
+
+ gl::disable(GL_DEPTH_TEST); // disable depth buffer writing
}
}