|
From: Tapio V. <aa...@us...> - 2010-11-02 22:41:12
|
Module: performous
Branch: opengl2
Commit: c90d21c4dc060eb9b839549b17378361d48a1e90
Author: Tapio Vierros <tap...@gm...>
Date: Wed Nov 3 00:38:03 2010 +0200
Refactor UseLighting into UseDepthTest.
* Because lighting is done entirely with shaders.
* Improves 3d object drawing and lighting.
* Still not good lighting.
---
game/glutil.hh | 25 ++++++-------------------
game/guitargraph.cc | 4 ++--
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/game/glutil.hh b/game/glutil.hh
index 9af0f77..b8185d7 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -46,26 +46,13 @@ namespace glutil {
};
/// wrapper struct for RAII
- struct UseLighting {
- /// enable lighting and depth test for 3d objects
- UseLighting(bool doit = true) {
- if (doit) {
- glClear(GL_DEPTH_BUFFER_BIT);
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-
- GLfloat light_position[] = { -50.0, 15.0, -5.0, 1.0 };
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHT0);
- }
+ struct UseDepthTest {
+ /// enable depth test (for 3d objects)
+ UseDepthTest() {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
}
- ~UseLighting() {
- glDisable(GL_LIGHT0);
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ ~UseDepthTest() {
glDisable(GL_DEPTH_TEST);
}
};
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 1516dc0..099c8e3 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -856,7 +856,7 @@ void GuitarGraph::draw(double time) {
// Draw the notes
{ UseShader objectShader(*Object3d::shader, *Window::shader);
- //glutil::UseLighting lighting(m_use3d);
+ glutil::UseDepthTest depthtest;
// Draw drum fills / Big Rock Endings
bool drumfill = m_dfIt != m_drumfills.end() && m_dfIt->begin - time <= future;
if (drumfill) {
@@ -922,7 +922,7 @@ void GuitarGraph::draw(double time) {
}
glutil::GLErrorChecker::reset(); // FIXME: There are errors here.
//glutil::GLErrorChecker glerror("GuitarGraph::draw - objects");
- } //< restore core shader
+ } //< restore core shader and disable depth test
// Draw flames
for (int fret = 0; fret < m_pads; ++fret) { // Loop through the frets
if (m_drums && fret == 0) { // Skip bass drum
|