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')
-rw-r--r--src/client/application.cc2
-rw-r--r--src/client/application.h12
-rw-r--r--src/client/view.cc98
3 files changed, 58 insertions, 54 deletions
diff --git a/src/client/application.cc b/src/client/application.cc
index b7505a1..7a88155 100644
--- a/src/client/application.cc
+++ b/src/client/application.cc
@@ -64,7 +64,7 @@ void Application::run()
// update the core chronometer
float seconds = ((float)(current - chrono)) / 1000.0f;
frame(seconds);
-
+
// update the video chronometers and draw
video.frame(seconds);
if (seconds > 0)
diff --git a/src/client/application.h b/src/client/application.h
index 62eccd6..150b24e 100644
--- a/src/client/application.h
+++ b/src/client/application.h
@@ -1,7 +1,7 @@
/*
client/application.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_CLIENT_APPLICATION_H__
@@ -9,10 +9,12 @@
#include "core/applicationinterface.h"
-namespace client {
+namespace client
+{
/// client Application implementation
-class Application : public core::ApplicationInterface {
+class Application : public core::ApplicationInterface
+{
public:
/// initialize the client Application
virtual void init();
@@ -25,7 +27,7 @@ public:
/// quit the client Application
virtual void quit(int status);
-
+
/// current fps
float current_fps;
};
diff --git a/src/client/view.cc b/src/client/view.cc
index 1dd0df6..811a7f7 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -1,7 +1,7 @@
-/*
+/*
view.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "client/client.h"
@@ -27,17 +27,18 @@ StarDrawer *stardrawer = 0;
game::Ship *target = 0; // the view's target
-void View::init() {
+void View::init()
+{
// draw scene
if (!shipdrawer) {
stardrawer = new StarDrawer(&game.star);
- shipdrawer = new ShipDrawer(&game.ship);
+ shipdrawer = new ShipDrawer(&game.ship);
target = &game.ship;
}
-
+
}
-void View::shutdown()
+void View::shutdown()
{
delete stardrawer;
stardrawer = 0;
@@ -45,26 +46,27 @@ void View::shutdown()
shipdrawer = 0;
}
-void View::reset() {
- // shading model: Gouraud (smooth).
+void View::reset()
+{
+ // shading model: Gouraud (smooth).
gl::shademodel(GL_SMOOTH);
// culling
- gl::cullface( GL_BACK );
- gl::frontface(GL_CCW );
+ gl::cullface(GL_BACK);
+ gl::frontface(GL_CCW);
// alpha-blending
- gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl::disable(GL_BLEND);
-
+
// depth
gl::depthmask(GL_TRUE);
gl::disable(GL_DEPTH_TEST);
- gl::disable( GL_CULL_FACE );
-}
+ gl::disable(GL_CULL_FACE);
+}
-void View::draw_world(float elapsed)
+void View::draw_world(float elapsed)
{
// draw the world
gl::push();
@@ -75,7 +77,7 @@ void View::draw_world(float elapsed)
gl::pop();
gl::push();
- gl::translate(game.star.location - target->location);
+ gl::translate(game.star.location - target->location);
stardrawer->draw(elapsed);
gl::pop();
@@ -84,7 +86,7 @@ void View::draw_world(float elapsed)
void View::draw_background(float elapsed)
{
using namespace gl;
-
+
// galactic axis
begin(Lines);
color(0.9f, 0.5f, 0.0f);
@@ -106,9 +108,9 @@ void View::draw_background(float elapsed)
float dx = target->location.x - floorf(target->location.x);
float dz = target->location.z - floorf(target->location.z);
- color(0,0, 1.0f);
- begin(Lines);
- for (int i=-gridsize; i <= gridsize; i++) {
+ color(0,0, 1.0f);
+ begin(Lines);
+ for (int i=-gridsize; i <= gridsize; i++) {
color(0,0, 0, 0);
vertex(i-dx, y, -gridsize-dz);
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
@@ -116,14 +118,14 @@ void View::draw_background(float elapsed)
vertex(i-dx, y, -dz);
color(0,0, 0, 0);
vertex(i-dx, y, gridsize-dz);
-
+
vertex(-gridsize-dx, y, i-dz);
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
vertex(-dx, y, i-dz);
vertex(-dx, y, i-dz);
color(0,0, 0, 0);
vertex(gridsize-dx, y, i-dz);
- }
+ }
end();
}
@@ -132,12 +134,12 @@ void View::draw_loader()
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);
-
+
gl::begin(gl::Quads);
-
+
glTexCoord2f(0.0f, 0.0f);
gl::vertex(0,0, 0);
-
+
glTexCoord2f(1.0f, 0.0f);
gl::vertex(video.width,0,0);
@@ -164,13 +166,13 @@ void View::draw_status()
// print the status in the upper left corner
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
std::stringstream 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;
+
+ 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;
minutes = (int) floorf(core::time() / 60.0f);
seconds = (int) floorf(core::time() - (float) minutes* 60.0f);
@@ -188,16 +190,16 @@ void View::draw_status()
gl::disable(GL_TEXTURE_2D);
}
-void View::frame(float seconds)
+void View::frame(float seconds)
{
// Clear the color and depth buffers.
- gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
+ gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
if (core::connected()) {
// draw the game world
-
+
// Change to the projection matrix and set our viewing volume.
- gl::matrixmode( GL_PROJECTION );
+ gl::matrixmode(GL_PROJECTION);
gl::loadidentity();
const float frustumsize = 0.5f;
@@ -207,32 +209,32 @@ void View::frame(float seconds)
height = 1;
gl::frustum(x, x+width, y, y +height, 1.0f, 1024.0f);
- gl::matrixmode( GL_MODELVIEW );
+ gl::matrixmode(GL_MODELVIEW);
gl::loadidentity();
gl::rotate(90.0f, 0, 1.0, 0);
-
+
// Camera transformation
camera.draw(seconds);
gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
gl::enable(GL_CULL_FACE); // enable culling
-
+
draw_world(seconds); // draw the world
- gl::disable(GL_CULL_FACE); // disable culling
+ gl::disable(GL_CULL_FACE); // disable culling
gl::enable(GL_BLEND); // enable alpha blending
- draw_background(seconds); // draw the spacegrid
+ draw_background(seconds); // draw the spacegrid
gl::disable(GL_DEPTH_TEST); // disable depth buffer writing
}
// switch to ortographic projection to draw the GUI
- gl::matrixmode( GL_PROJECTION );
- gl::loadidentity();
+ gl::matrixmode(GL_PROJECTION);
+ gl::loadidentity();
glOrtho(0, video.width, video.height, 0, -1000.0f, 1000.0f);
-
- gl::matrixmode( GL_MODELVIEW );
+
+ gl::matrixmode(GL_MODELVIEW);
gl::loadidentity();
if (!core::connected()) {
@@ -240,7 +242,7 @@ void View::frame(float seconds)
draw_loader();
gl::enable(GL_BLEND); // enable alpha blending
}
-
+
// draw the console
console.draw();