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.cc59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/client/view.cc b/src/client/view.cc
index 8ddd33c..1863d00 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -4,6 +4,13 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include <GL/gl.h>
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <iomanip>
+
#include "client/client.h"
#include "client/camera.h"
#include "client/chat.h"
@@ -15,11 +22,6 @@
#include "math/mathlib.h"
#include "sys/sys.h"
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <iomanip>
-
namespace client
{
@@ -45,21 +47,42 @@ void reset()
// set clear color
gl::clearcolor(0.0f, 0.0f, 0.0f, 1.0f);
- // shading model: Gouraud (smooth).
+ // shading model: Gouraud (smooth, the default)
gl::shademodel(GL_SMOOTH);
+ //gl::shademodel(GL_FLAT);
+
+ // lighting
+ GLfloat ambient_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+ GLfloat diffuse_light[] = { 0.6f, 0.6f, 0.6f, 1.0f };
+ GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+ GLfloat specular_reflectance[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light);
+ glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light);
+
+ // color tracking
+ glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
+
+ glMaterialfv(GL_FRONT, GL_SPECULAR, specular_reflectance);
+ glMateriali(GL_FRONT, GL_SHININESS, 16); // shininess 1-128
+ gl::disable(GL_LIGHTING);
+ gl::disable(GL_LIGHT0);
+ gl::disable(GL_COLOR_MATERIAL);
+
// culling
gl::cullface(GL_BACK);
gl::frontface(GL_CCW);
-
- // alpha-blending
- gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- gl::disable(GL_BLEND);
+ gl::disable(GL_CULL_FACE);
// depth
gl::depthmask(GL_TRUE);
- gl::disable(GL_DEPTH_TEST);
- gl::disable(GL_CULL_FACE);
+ gl::disable(GL_DEPTH_TEST);
+
+ // alpha-blending
+ gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl::enable(GL_BLEND);
}
void draw_loader()
@@ -169,6 +192,7 @@ void frame(float seconds)
gl::matrixmode(GL_PROJECTION);
gl::loadidentity();
+ // FIXME width must always be one
const float frustumsize = 0.5f;
gl::frustum(-frustumsize*video::aspect, frustumsize*video::aspect, -frustumsize, frustumsize, 1.0f, 1024.0f);
@@ -177,14 +201,7 @@ void frame(float seconds)
camera::draw(seconds); // draw the current camera transformation
- gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
- gl::enable(GL_CULL_FACE); // enable culling
- gl::enable(GL_BLEND); // enable alpha blending
-
draw_world(seconds); // draw the world
-
- gl::disable(GL_CULL_FACE); // disable culling
- gl::disable(GL_DEPTH_TEST); // disable depth buffer writing
}
// switch to ortographic projection to draw the GUI
@@ -198,7 +215,6 @@ void frame(float seconds)
if (!core::application()->connected()) {
// draw the loader bitmap
draw_loader();
- gl::enable(GL_BLEND); // enable alpha blending
}
// draw the console
@@ -207,9 +223,6 @@ void frame(float seconds)
// draw the status line
draw_status();
-
- gl::disable(GL_BLEND);
-
}
} //namespace view