From 48aa068b036f565d6b94d4207242066ba655afe4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Feb 2008 17:48:16 +0000 Subject: entities, step 1 --- src/client/view.cc | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'src/client/view.cc') diff --git a/src/client/view.cc b/src/client/view.cc index 07e7cff..4627d26 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -7,9 +7,8 @@ #include "client/client.h" #include "client/camera.h" #include "client/console.h" -#include "client/shipdrawer.h" -#include "client/stardrawer.h" #include "client/video.h" +#include "client/draw.h" #include "render/render.h" #include "game/game.h" #include "sys/sys.h" @@ -26,31 +25,16 @@ namespace client namespace view { -ShipDrawer *shipdrawer = 0; -StarDrawer *stardrawer = 0; -game::Ship *target = 0; // the view's target - float fps = 0; void init() { - if (!shipdrawer) { - stardrawer = new StarDrawer(&game.star); - shipdrawer = new ShipDrawer(&game.ship); - target = &game.ship; - } - camera::init(); } void shutdown() { camera::shutdown(); - - delete stardrawer; - stardrawer = 0; - delete shipdrawer; - shipdrawer = 0; } void reset() @@ -77,26 +61,6 @@ void reset() gl::disable(GL_CULL_FACE); } - -void draw_world(float elapsed) -{ - using namespace render; - - // draw the world - gl::push(); - - gl::translate(game.ship.location - target->location); - gl::scale(0.2f, 0.2f, 0.2f); - shipdrawer->draw(elapsed); - gl::pop(); - - gl::push(); - gl::translate(game.star.location - target->location); - stardrawer->draw(elapsed); - gl::pop(); - -} - void draw_background(float elapsed) { using namespace render::gl; @@ -115,12 +79,14 @@ void draw_background(float elapsed) vertex(0,-1, 0); end(); + translate(camera::target); + int gridsize = 32; float s = 1.0f / gridsize; float y = -4.0f; - float dx = target->location.x - floorf(target->location.x); - float dz = target->location.z - floorf(target->location.z); + float dx = camera::target.x - floorf(camera::target.x); + float dz = camera::target.z - floorf(camera::target.z); color(0,0, 1.0f); begin(Lines); @@ -233,6 +199,7 @@ void frame(float seconds) gl::loadidentity(); gl::rotate(90.0f, 0, 1.0, 0); + camera::target = game.ship->location; camera::draw(seconds); // draw the current camera transformation gl::enable(GL_DEPTH_TEST); // enable depth buffer writing -- cgit v1.2.3