diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-10-24 15:03:18 +0400 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-10-24 15:03:18 +0400 |
commit | 657eff7ed7f23e9218a22ff6b3c96d331d69dd47 (patch) | |
tree | f9a7c7a0e95fd40c6c6f3300f6248f23b3e9041b /source/gameengine/Rasterizer | |
parent | 6424bf6eb02345cc4e8db0951edba97993dce301 (diff) |
Port stereo stuff from tuhopuu2: anaglyph, vinterlace
Diffstat (limited to 'source/gameengine/Rasterizer')
3 files changed, 72 insertions, 7 deletions
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 60edec7ada9..bd7f10e32a7 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -93,7 +93,10 @@ public: RAS_STEREO_ABOVEBELOW, RAS_STEREO_INTERLACED, RAS_STEREO_ANAGLYPH, - RAS_STEREO_SIDEBYSIDE + RAS_STEREO_SIDEBYSIDE, + RAS_STEREO_VINTERLACE, + + RAS_STEREO_MAXSTEREO }; /** * Render pass identifiers for stereo. @@ -157,12 +160,17 @@ public: * Sets which eye buffer subsequent primitives will be rendered to. */ virtual void SetEye(const StereoEye eye)=0; + virtual StereoEye GetEye()=0; /** + * Sets the distance between eyes for stereo mode. */ virtual void SetEyeSeparation(const float eyeseparation)=0; + virtual float GetEyeSeparation() = 0; /** + * Sets the focal length for stereo mode. */ virtual void SetFocalLength(const float focallength)=0; + virtual float GetFocalLength() = 0; /** * SwapBuffers swaps the back buffer with the front buffer. */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 8b949ac57b6..803ccbc2b63 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -58,6 +58,8 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) m_time(0.0), m_stereomode(RAS_STEREO_NOSTEREO), m_curreye(RAS_STEREO_LEFTEYE), + m_eyeseparation(-1.0f), + m_focallength(-1.0f), m_noOfScanlines(32), m_materialCachingInfo(0) { @@ -265,7 +267,9 @@ void RAS_OpenGLRasterizer::Exit() glDepthMask (GL_TRUE); glDepthFunc(GL_LEQUAL); glBlendFunc(GL_ONE, GL_ZERO); - + + glDisable(GL_POLYGON_STIPPLE); + glDisable(GL_LIGHTING); if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); @@ -273,15 +277,21 @@ void RAS_OpenGLRasterizer::Exit() EndFrame(); } - +bool RAS_OpenGLRasterizer::InterlacedStereo() const +{ + return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED; +} bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) { m_time = time; m_drawingmode = drawingmode; - m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback); - m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER); + if (!InterlacedStereo() || m_curreye == RAS_STEREO_LEFTEYE) + { + m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback); + m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER); + } // Blender camera routine destroys the settings if (m_drawingmode < KX_SOLID) @@ -459,23 +469,63 @@ void RAS_OpenGLRasterizer::SetEye(StereoEye eye) ClearDepthBuffer(); } break; + case RAS_STEREO_VINTERLACE: + { + GLuint pat[32]; + const unsigned char mask = 0x55; // 01010101 + memset(pat, m_curreye == RAS_STEREO_RIGHTEYE?~mask:mask, sizeof(pat)); + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple((const GLubyte*) pat); + if (m_curreye == RAS_STEREO_RIGHTEYE) + ClearDepthBuffer(); + break; + } + case RAS_STEREO_INTERLACED: + { + GLuint pat[32]; + GLuint mask = m_curreye == RAS_STEREO_LEFTEYE?~0:0; + for (int y = 0; y < 32; y+=2) + { + pat[y] = mask; + pat[y+1] = ~mask; + } + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple((const GLubyte*) pat); + if (m_curreye == RAS_STEREO_RIGHTEYE) + ClearDepthBuffer(); + break; + } default: break; } } +RAS_IRasterizer::StereoEye RAS_OpenGLRasterizer::GetEye() +{ + return m_curreye; +} + void RAS_OpenGLRasterizer::SetEyeSeparation(float eyeseparation) { m_eyeseparation = eyeseparation; } +float RAS_OpenGLRasterizer::GetEyeSeparation() +{ + return m_eyeseparation; +} void RAS_OpenGLRasterizer::SetFocalLength(float focallength) { m_focallength = focallength; } +float RAS_OpenGLRasterizer::GetFocalLength() +{ + return m_focallength; +} + void RAS_OpenGLRasterizer::SwapBuffers() { @@ -1109,8 +1159,10 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( { float near_div_focallength; // next 2 params should be specified on command line and in Blender publisher - m_focallength = 1.5 * right; // derived from example - m_eyeseparation = 0.18 * right; // just a guess... + if (m_focallength < 0.0f) + m_focallength = 1.5 * right; // derived from example + if (m_eyeseparation < 0.0f) + m_eyeseparation = 0.18 * right; // just a guess... near_div_focallength = frustnear / m_focallength; switch(m_curreye) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 4e63697b7ed..9ab7b772cf9 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -74,6 +74,8 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer float m_eyeseparation; float m_focallength; int m_noOfScanlines; + + bool InterlacedStereo() const; protected: int m_drawingmode; @@ -113,8 +115,11 @@ public: virtual void SetStereoMode(const StereoMode stereomode); virtual bool Stereo(); virtual void SetEye(const StereoEye eye); + virtual StereoEye GetEye(); virtual void SetEyeSeparation(const float eyeseparation); + virtual float GetEyeSeparation(); virtual void SetFocalLength(const float focallength); + virtual float GetFocalLength(); virtual void SwapBuffers(); virtual void IndexPrimitives( |