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/view.cc')
-rw-r--r--src/client/view.cc41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/client/view.cc b/src/client/view.cc
index 3641261..d9b5f42 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -10,15 +10,14 @@
#include <SDL/SDL.h>
// project headers
+#include "osirion.h"
#include "common/functions.h"
-#include "common/osirion.h"
#include "game/game.h"
#include "gl/osiriongl.h"
#include "video.h"
#include "camera.h"
-
#include "shipdrawer.h"
#include "stardrawer.h"
@@ -55,7 +54,7 @@ void reset() {
//glu::perspective( 64.0, video::ratio, 1.0, 1024.0 );
const float frustumsize=0.5f;
- gl::frustum( -frustumsize * video::ratio, frustumsize * video::ratio, -frustumsize, frustumsize, 1.0, 1024.0);
+ gl::frustum( -frustumsize * video::ratio, frustumsize * video::ratio, -frustumsize, frustumsize, 1.0f, 1024.0f);
/*
map world coordinates to GL coordinates
@@ -69,17 +68,21 @@ void reset() {
void draw_background()
{
using namespace gl;
+
+// // // enable Alpha blending
+ gl::enable(GL_BLEND);
+ // galactic axis
begin(Lines);
color(0.9f, 0.5f, 0.0f);
- vertex(-2,1,0);
+ vertex(-2,0,0);
color(1.0f, 1.0f, 0.0f);
- vertex(2,1,0);
+ vertex(2,0,0);
- vertex(0,1,-0.5);
- vertex(0,1,0.5);
+ vertex(0,0,-0.5);
+ vertex(0,0,0.5);
- vertex(0,2.0f,0);
+ vertex(0,1.0f,0);
vertex(0,-1, 0);
end();
@@ -93,22 +96,24 @@ void draw_background()
color(0,0, 1.0f);
begin(Lines);
for (int i=-gridsize; i <= gridsize; i++) {
- color(0,0, 0);
+ color(0,0, 0, 0);
vertex(i-dx, y, -gridsize-dz);
- color(0,0, (gridsize-abs(i))*s);
+ color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
vertex(i-dx, y, -dz);
vertex(i-dx, y, -dz);
- color(0,0, 0);
+ color(0,0, 0, 0);
vertex(i-dx, y, gridsize-dz);
vertex(-gridsize-dx, y, i-dz);
- color(0,0, (gridsize-abs(i))*s);
+ 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);
+ color(0,0, 0, 0);
vertex(gridsize-dx, y, i-dz);
}
end();
+
+ gl::disable(GL_BLEND);
}
void draw_world(float elapsed)
@@ -118,13 +123,15 @@ void draw_world(float elapsed)
//std::cerr << "ship at " << game::ship.location << " translate " << game::ship.location - target->location << std::endl;
gl::translate(game::ship.location - target->location);
- gl::scale(GAMESCALE, GAMESCALE, GAMESCALE);
+ gl::scale(0.2f, 0.2f, 0.2f);
shipdrawer->draw(elapsed);
gl::pop();
//std::cerr << "star at " << game::star.location << " translate " << game::star.location - game::ship.location << std::endl;
+ gl::push();
gl::translate(game::star.location - target->location);
stardrawer->draw(elapsed);
+ gl::pop();
}
@@ -140,11 +147,11 @@ void draw(float elapsed)
// Camera transformation
camera::draw(elapsed);
- // draw the semi-static background
- draw_background();
-
// draw the world
draw_world(elapsed);
+
+ // draw the semi-static background
+ draw_background();
SDL_GL_SwapBuffers( );
}