diff options
Diffstat (limited to 'src/client/view.cc')
-rw-r--r-- | src/client/view.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/client/view.cc b/src/client/view.cc index 87afd38..07e7cff 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -5,8 +5,11 @@ */ #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 "render/render.h" #include "game/game.h" #include "sys/sys.h" @@ -17,8 +20,6 @@ #include <sstream> #include <iomanip> -using namespace render; - namespace client { @@ -27,9 +28,10 @@ namespace view ShipDrawer *shipdrawer = 0; StarDrawer *stardrawer = 0; - game::Ship *target = 0; // the view's target +float fps = 0; + void init() { if (!shipdrawer) { @@ -53,6 +55,8 @@ void shutdown() void reset() { + using namespace render; + // set clear color gl::clearcolor(0.0f, 0.0f, 0.0f, 1.0f); @@ -76,6 +80,8 @@ void reset() void draw_world(float elapsed) { + using namespace render; + // draw the world gl::push(); @@ -93,7 +99,7 @@ void draw_world(float elapsed) void draw_background(float elapsed) { - using namespace gl; + using namespace render::gl; // galactic axis begin(Lines); @@ -139,6 +145,8 @@ void draw_background(float elapsed) void draw_loader() { + using namespace render; + gl::enable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, render::textures[0]); // bitmaps/loader.tga gl::color(1.0f, 1.0f, 1.0f, 1.0f); @@ -163,9 +171,9 @@ void draw_loader() void draw_status() { - using namespace std; + using namespace render; - if (console.visible()) + if (console::visible()) return; glBindTexture(GL_TEXTURE_2D, render::textures[1]); // bitmaps/conchars.tga @@ -178,15 +186,15 @@ void draw_status() int hours = (int) sys::time() / 3600; int minutes = (int)(sys::time() - 3600*hours) / 60; int seconds = (int)(sys::time() - 3600*hours - 60 *minutes); - status << " clock " << setfill('0') << setw(2) << hours << ":" - << setfill('0') << setw(2) << minutes << ":" - << setfill('0') << setw(2) << seconds; + status << " clock " << std::setfill('0') << std::setw(2) << hours << ":" + << std::setfill('0') << std::setw(2) << minutes << ":" + << std::setfill('0') << std::setw(2) << seconds; minutes = (int) floorf(core::time() / 60.0f); seconds = (int) floorf(core::time() - (float) minutes* 60.0f); - status << " time " << setfill('0') << setw(2) << minutes << ":" << setfill('0') << setw(2) << seconds; - status << " fps " << setw(4) << client::fps(); + status << " time " << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds; + status << " fps " << std::setw(4) << fps; draw_text(0, 4, status); // print the version number in the upper right corner @@ -200,6 +208,14 @@ void draw_status() void frame(float seconds) { + using namespace render; + + // calculate frames per second + if (seconds > 0.0f) + fps = floorf(1.0f / seconds); + else + fps = 9999; + // Clear the color and depth buffers. gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -247,7 +263,7 @@ void frame(float seconds) } // draw the console - console.draw(); + console::draw(); // draw the status line draw_status(); |