|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-28 01:01:55
|
Module: performous
Branch: opengl2
Commit: e8c2622e43b4168611b669f0b42e07e0982dddfd
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jan 28 02:01:43 2011 +0100
Fix 3d separation handling + cleanup.
---
data/schema.xml | 2 +-
game/video_driver.cc | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index ab20020..0bebc88 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -140,7 +140,7 @@ to save the current settings to XML.
</entry>
<entry name="graphic/stereo3dseparation" type="float" value="50">
<ui unit=" %" />
- <limits min="0" max="100" step="1" />
+ <limits min="0" max="100" step="2" />
<locale name="C">
<short>Stereo3D separation</short>
<long>The strenght of the effect. Experiment with different settings for best results.</long>
diff --git a/game/video_driver.cc b/game/video_driver.cc
index caed025..336f179 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -31,6 +31,10 @@ namespace {
int m_value;
};
+ double getSeparation() {
+ return config["graphic/stereo3d"].b() ? 0.001f * config["graphic/stereo3dseparation"].f() : 0.0;
+ }
+
// stump: under MSVC, near and far are #defined to nothing for compatibility with ancient code, hence the underscores.
const float near_ = 0.1f; // This determines the near clipping distance (must be > 0)
const float far_ = 110.0f; // How far away can things be seen
@@ -102,7 +106,7 @@ bool Window::view(unsigned num) {
glmath::Matrix colorMatrix;
if (stereo) {
if (num > 1) return false;
- double separation = 0.0004f * (num ? -1 : 1) * config["graphic/stereo3dseparation"].f();
+ double separation = (num ? -1 : 1) * getSeparation();
glMatrixMode(GL_PROJECTION);
glTranslatef(separation, 0.0f, 0.0f);
glMatrixMode(GL_MODELVIEW);
@@ -197,7 +201,7 @@ void Window::resize() {
FarTransform::FarTransform() {
float z = far_ - 0.1f; // Very near the far plane but just a bit closer to avoid accidental clipping
float s = z / z0; // Scale the image so that it looks the same size
- s *= 1.04; // A bit more for stereo3d (avoid black borders)
+ s *= 1.0 + 2.0 * getSeparation(); // A bit more for stereo3d (avoid black borders)
glTranslatef(0.0f, 0.0f, -z + z0); // Very near the farplane
glScalef(s, s, s);
}
|