|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 00:45:19
|
Module: performous
Branch: opengl2
Commit: 86c8a3df624212a038776e064f0bddcf4b5801cb
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Feb 7 00:18:56 2011 +0100
Fix view setup so that non-stereo doesn't render left eye.
---
game/video_driver.cc | 23 +++++++++--------------
game/video_driver.hh | 7 +++----
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 3c8a3fc..0e1b458 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -123,7 +123,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
for (unsigned i = 0; i < 2; ++i) {
UseFBO user(*fbo[i]);
glViewport(0, 0, w, h); // Full FBO
- view(i);
+ view(i + 1);
drawFunc();
}
// Render to actual framebuffer from FBOs
@@ -177,7 +177,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
}
}
-bool Window::view(unsigned num) {
+void Window::view(unsigned num) {
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
@@ -202,18 +202,13 @@ bool Window::view(unsigned num) {
* translate(Vec3(0.0, 0.0, -z0))
);
// Setup views
- bool stereo = config["graphic/stereo3d"].b();
- if (stereo) {
- if (num > 1) return false;
- double separation = (num == 0 ? -1 : 1) * getSeparation();
- glMatrixMode(GL_PROJECTION);
- glTranslatef(separation, 0.0f, 0.0f);
- glMatrixMode(GL_MODELVIEW);
- glTranslatef(-separation, 0.0f, 0.0f);
- } else {
- if (num != 0) return false;
- }
- return true;
+ if (num == 0) return; // Center (non-stereo)
+ // Stereo separation
+ double separation = (num == 1 ? -1 : 1) * getSeparation();
+ glMatrixMode(GL_PROJECTION);
+ glTranslatef(separation, 0.0f, 0.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(-separation, 0.0f, 0.0f);
}
void Window::swap() {
diff --git a/game/video_driver.hh b/game/video_driver.hh
index d9e4209..3546219 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -27,10 +27,6 @@ public:
/// destructor
~Window();
void render(boost::function<void (void)> drawFunc);
- /// Setup everything for drawing a view.
- /// @param num should be 0 the first time each frame then incremented for each additional view
- /// @returns true if the view should be rendered, false if no more views are available
- bool view(unsigned num);
/// clears window
void blank();
/// swaps buffers
@@ -57,6 +53,9 @@ public:
/// Construct a new shader or return an existing one by name
Shader& shader(std::string const& name) { return m_shaders[name]; }
private:
+ /// Setup everything for drawing a view.
+ /// @param num 0 = no stereo, 1 = left eye, 2 = right eye
+ void view(unsigned num);
SDL_Surface* screen;
unsigned int m_windowW, m_windowH;
unsigned int m_fsW, m_fsH;
|