]> git.tdb.fi Git - libs/vr.git/commitdiff
Rename to mspvr
authorMikko Rasa <tdb@tdb.fi>
Fri, 13 Sep 2013 13:22:55 +0000 (16:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 13 Sep 2013 13:22:55 +0000 (16:22 +0300)
source/oculusriftcombiner.cpp
source/oculusriftcombiner.h
source/sidebysidecombiner.cpp
source/sidebysidecombiner.h
source/stereocombiner.cpp
source/stereocombiner.h
source/stereoview.cpp
source/stereoview.h

index 9d985d9268e679584419bb2c75bb4947ce22aeef..771f3b82a3cd7df48f48854b10e7b786c931bc72 100644 (file)
@@ -1,7 +1,7 @@
 #include <cmath>
 #include <cmath>
-#include "meshbuilder.h"
+#include <msp/gl/meshbuilder.h>
+#include <msp/gl/texture2d.h>
 #include "oculusriftcombiner.h"
 #include "oculusriftcombiner.h"
-#include "texture2d.h"
 
 using namespace std;
 
 
 using namespace std;
 
@@ -41,10 +41,10 @@ const char fs_source[] =
 }
 
 namespace Msp {
 }
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 OculusRiftCombiner::OculusRiftCombiner():
 
 OculusRiftCombiner::OculusRiftCombiner():
-       mesh(VERTEX2),
+       mesh(GL::VERTEX2),
        shprog(vs_source, fs_source),
        // Default values copied from the SDK
        view_distance(0.438f),
        shprog(vs_source, fs_source),
        // Default values copied from the SDK
        view_distance(0.438f),
@@ -62,8 +62,8 @@ OculusRiftCombiner::OculusRiftCombiner():
        // This will also call update_parameters
        set_distortion(1.0f, 0.22f, 0.24f);
 
        // This will also call update_parameters
        set_distortion(1.0f, 0.22f, 0.24f);
 
-       MeshBuilder bld(mesh);
-       bld.begin(TRIANGLE_STRIP);
+       GL::MeshBuilder bld(mesh);
+       bld.begin(GL::TRIANGLE_STRIP);
        bld.vertex(-1, 1);
        bld.vertex(-1, -1);
        bld.vertex(1, 1);
        bld.vertex(-1, 1);
        bld.vertex(-1, -1);
        bld.vertex(1, 1);
@@ -153,11 +153,11 @@ float OculusRiftCombiner::undistort(float r) const
        }
 }
 
        }
 }
 
-void OculusRiftCombiner::render(const Texture2D &left, const Texture2D &right) const
+void OculusRiftCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
 {
 {
-       Bind bind_shprog(shprog);
+       GL::Bind bind_shprog(shprog);
 
 
-       Bind bind_tex(left);
+       GL::Bind bind_tex(left);
        left_shdata.apply();
        mesh.draw();
 
        left_shdata.apply();
        mesh.draw();
 
@@ -166,5 +166,5 @@ void OculusRiftCombiner::render(const Texture2D &left, const Texture2D &right) c
        mesh.draw();
 }
 
        mesh.draw();
 }
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 } // namespace Msp
index ede2fe91e481585de3e72bb165a8b4481a96b44f..a204c3eff766b25085095cdc4e6020f99423029b 100644 (file)
@@ -1,13 +1,13 @@
-#ifndef MSP_GL_OCULUSRIFTCOMBINER_H_
-#define MSP_GL_OCULUSRIFTCOMBINER_H_
+#ifndef MSP_VR_OCULUSRIFTCOMBINER_H_
+#define MSP_VR_OCULUSRIFTCOMBINER_H_
 
 
-#include "mesh.h"
-#include "program.h"
-#include "programdata.h"
+#include <msp/gl/mesh.h>
+#include <msp/gl/program.h>
+#include <msp/gl/programdata.h>
 #include "stereocombiner.h"
 
 namespace Msp {
 #include "stereocombiner.h"
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 /**
 Presents a stereo view in a way suitable for an Oculus Rift HMD.  All distances
 
 /**
 Presents a stereo view in a way suitable for an Oculus Rift HMD.  All distances
@@ -16,10 +16,10 @@ are specified in multiples of the screen width.
 class OculusRiftCombiner: public StereoCombiner
 {
 private:
 class OculusRiftCombiner: public StereoCombiner
 {
 private:
-       Mesh mesh;
-       Program shprog;
-       ProgramData left_shdata;
-       ProgramData right_shdata;
+       GL::Mesh mesh;
+       GL::Program shprog;
+       GL::ProgramData left_shdata;
+       GL::ProgramData right_shdata;
        float view_distance;
        float lens_separation;
        float eye_separation;
        float view_distance;
        float lens_separation;
        float eye_separation;
@@ -41,10 +41,10 @@ private:
        float undistort(float) const;
 
 public:
        float undistort(float) const;
 
 public:
-       virtual void render(const Texture2D &, const Texture2D &) const;
+       virtual void render(const GL::Texture2D &, const GL::Texture2D &) const;
 };
 
 };
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 
 #endif
 } // namespace Msp
 
 #endif
index b9d1d89c243023faf1def099df849dc7b05b8d56..213b5448249b894736d392e55c741235d10e438b 100644 (file)
@@ -1,6 +1,6 @@
-#include "meshbuilder.h"
+#include <msp/gl/meshbuilder.h>
+#include <msp/gl/texture2d.h>
 #include "sidebysidecombiner.h"
 #include "sidebysidecombiner.h"
-#include "texture2d.h"
 
 namespace {
 
 
 namespace {
 
@@ -24,10 +24,10 @@ const char fs_source[] =
 }
 
 namespace Msp {
 }
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 SideBySideCombiner::SideBySideCombiner(bool c):
 
 SideBySideCombiner::SideBySideCombiner(bool c):
-       mesh(VERTEX2),
+       mesh(GL::VERTEX2),
        shprog(vs_source, fs_source)
 {
        width_div = 2;
        shprog(vs_source, fs_source)
 {
        width_div = 2;
@@ -37,8 +37,8 @@ SideBySideCombiner::SideBySideCombiner(bool c):
 
        set_cross_eyed(c);
 
 
        set_cross_eyed(c);
 
-       MeshBuilder bld(mesh);
-       bld.begin(TRIANGLE_STRIP);
+       GL::MeshBuilder bld(mesh);
+       bld.begin(GL::TRIANGLE_STRIP);
        bld.vertex(-1, 1);
        bld.vertex(-1, -1);
        bld.vertex(1, 1);
        bld.vertex(-1, 1);
        bld.vertex(-1, -1);
        bld.vertex(1, 1);
@@ -54,11 +54,11 @@ void SideBySideCombiner::set_cross_eyed(bool c)
        right_shdata.uniform("offset", m);
 }
 
        right_shdata.uniform("offset", m);
 }
 
-void SideBySideCombiner::render(const Texture2D &left, const Texture2D &right) const
+void SideBySideCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
 {
 {
-       Bind bind_shprog(shprog);
+       GL::Bind bind_shprog(shprog);
 
 
-       Bind bind_tex(left);
+       GL::Bind bind_tex(left);
        left_shdata.apply();
        mesh.draw();
 
        left_shdata.apply();
        mesh.draw();
 
@@ -67,5 +67,5 @@ void SideBySideCombiner::render(const Texture2D &left, const Texture2D &right) c
        mesh.draw();
 }
 
        mesh.draw();
 }
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 } // namespace Msp
index f6ec593a1ed471ba15caf40187c782d22d8488a6..52eda28ab75ec5361574f49ac9ec7e8a095b801d 100644 (file)
@@ -1,21 +1,21 @@
-#ifndef MSP_GL_SIDEBYSIDECOMBINER_H_
-#define MSP_GL_SIDEBYSIDECOMBINER_H_
+#ifndef MSP_VR_SIDEBYSIDECOMBINER_H_
+#define MSP_VR_SIDEBYSIDECOMBINER_H_
 
 
-#include "mesh.h"
-#include "program.h"
-#include "programdata.h"
+#include <msp/gl/mesh.h>
+#include <msp/gl/program.h>
+#include <msp/gl/programdata.h>
 #include "stereocombiner.h"
 
 namespace Msp {
 #include "stereocombiner.h"
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 class SideBySideCombiner: public StereoCombiner
 {
 private:
 
 class SideBySideCombiner: public StereoCombiner
 {
 private:
-       Mesh mesh;
-       Program shprog;
-       ProgramData left_shdata;
-       ProgramData right_shdata;
+       GL::Mesh mesh;
+       GL::Program shprog;
+       GL::ProgramData left_shdata;
+       GL::ProgramData right_shdata;
        bool cross_eyed;
 
 public:
        bool cross_eyed;
 
 public:
@@ -23,10 +23,10 @@ public:
 
        void set_cross_eyed(bool);
 
 
        void set_cross_eyed(bool);
 
-       virtual void render(const Texture2D &, const Texture2D &) const;
+       virtual void render(const GL::Texture2D &, const GL::Texture2D &) const;
 };
 
 };
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 
 #endif
 } // namespace Msp
 
 #endif
index ba71818d743c56ae3d6b464942d48f5e6c5f0b2c..54ab3e3218e7e265d4e9c88b72163ca0cca9d321 100644 (file)
@@ -1,7 +1,7 @@
 #include "stereocombiner.h"
 
 namespace Msp {
 #include "stereocombiner.h"
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 StereoCombiner::StereoCombiner():
        width_div(1),
 
 StereoCombiner::StereoCombiner():
        width_div(1),
@@ -10,5 +10,5 @@ StereoCombiner::StereoCombiner():
        oversize(1.0f)
 { }
 
        oversize(1.0f)
 { }
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 } // namespace Msp
index 5fb8dec7e5154fd716e2a93419ec641f2c204a6a..f078df773592531fe9b8ad79b3aa74d6321b5bc2 100644 (file)
@@ -1,12 +1,11 @@
-#ifndef MSP_GL_STEREOCOMBINER_H_
-#define MSP_GL_STEREOCOMBINER_H_
+#ifndef MSP_VR_STEREOCOMBINER_H_
+#define MSP_VR_STEREOCOMBINER_H_
 
 #include <msp/geometry/angle.h>
 
 #include <msp/geometry/angle.h>
+#include <msp/gl/texture2d.h>
 
 namespace Msp {
 
 namespace Msp {
-namespace GL {
-
-class Texture2D;
+namespace VR {
 
 class StereoCombiner
 {
 
 class StereoCombiner
 {
@@ -27,10 +26,10 @@ public:
        const Geometry::Angle<float> &get_field_of_view() const { return fov; }
        float get_oversize() const { return oversize; }
 
        const Geometry::Angle<float> &get_field_of_view() const { return fov; }
        float get_oversize() const { return oversize; }
 
-       virtual void render(const Texture2D &, const Texture2D &) const = 0;
+       virtual void render(const GL::Texture2D &, const GL::Texture2D &) const = 0;
 };
 
 };
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 
 #endif
 } // namespace Msp
 
 #endif
index 53c6445f368b28266aba2ca372ab40a52fa3a4e6..02c60acce33a885ec0517c25d955a855b2ba4a80 100644 (file)
@@ -1,13 +1,13 @@
-#include "renderer.h"
+#include <msp/gl/renderer.h>
 #include "stereocombiner.h"
 #include "stereoview.h"
 
 using namespace std;
 
 namespace Msp {
 #include "stereocombiner.h"
 #include "stereoview.h"
 
 using namespace std;
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 
-StereoView::StereoView(unsigned w, unsigned h, const Camera &c, const Renderable &r, const StereoCombiner &m):
+StereoView::StereoView(unsigned w, unsigned h, const GL::Camera &c, const GL::Renderable &r, const StereoCombiner &m):
        width(w),
        height(h),
        base_camera(c),
        width(w),
        height(h),
        base_camera(c),
@@ -60,7 +60,7 @@ void StereoView::finish_frame() const
        renderable.finish_frame();
 }
 
        renderable.finish_frame();
 }
 
-void StereoView::render(const Tag &tag) const
+void StereoView::render(const GL::Tag &tag) const
 {
        setup_frame();
        left.render(renderable, tag);
 {
        setup_frame();
        left.render(renderable, tag);
@@ -69,7 +69,7 @@ void StereoView::render(const Tag &tag) const
        finish_frame();
 }
 
        finish_frame();
 }
 
-void StereoView::render(Renderer &renderer, const Tag &tag) const
+void StereoView::render(GL::Renderer &renderer, const GL::Tag &tag) const
 {
        renderer.escape();
        return render(tag);
 {
        renderer.escape();
        return render(tag);
@@ -78,13 +78,13 @@ void StereoView::render(Renderer &renderer, const Tag &tag) const
 
 StereoView::RenderTarget::RenderTarget(unsigned width, unsigned height)
 {
 
 StereoView::RenderTarget::RenderTarget(unsigned width, unsigned height)
 {
-       color.set_min_filter(LINEAR);
-       color.set_wrap(CLAMP_TO_EDGE);
-       color.storage(RGB, width, height);
-       fbo.attach(COLOR_ATTACHMENT0, color);
+       color.set_min_filter(GL::LINEAR);
+       color.set_wrap(GL::CLAMP_TO_EDGE);
+       color.storage(GL::RGB, width, height);
+       fbo.attach(GL::COLOR_ATTACHMENT0, color);
 
 
-       depth.storage(DEPTH_COMPONENT, width, height);
-       fbo.attach(DEPTH_ATTACHMENT, depth);
+       depth.storage(GL::DEPTH_COMPONENT, width, height);
+       fbo.attach(GL::DEPTH_ATTACHMENT, depth);
 }
 
 
 }
 
 
@@ -98,7 +98,7 @@ void StereoView::Eye::create_target(unsigned w, unsigned h)
        target = new RenderTarget(w, h);
 }
 
        target = new RenderTarget(w, h);
 }
 
-void StereoView::Eye::setup_frame(const Camera &base_camera, const Vector3 &offset, const EyeParams &params) const
+void StereoView::Eye::setup_frame(const GL::Camera &base_camera, const GL::Vector3 &offset, const EyeParams &params) const
 {
        camera.set_position(base_camera.get_position()+offset);
        camera.set_up_direction(base_camera.get_up_direction());
 {
        camera.set_position(base_camera.get_position()+offset);
        camera.set_up_direction(base_camera.get_up_direction());
@@ -109,12 +109,12 @@ void StereoView::Eye::setup_frame(const Camera &base_camera, const Vector3 &offs
        camera.set_depth_clip(params.near_clip, params.far_clip);
 }
 
        camera.set_depth_clip(params.near_clip, params.far_clip);
 }
 
-void StereoView::Eye::render(const Renderable &renderable, const Tag &tag) const
+void StereoView::Eye::render(const GL::Renderable &renderable, const GL::Tag &tag) const
 {
 {
-       Bind bind_fbo(target->fbo);
-       Renderer renderer(&camera);
+       GL::Bind bind_fbo(target->fbo);
+       GL::Renderer renderer(&camera);
        renderable.render(renderer, tag);
 }
 
        renderable.render(renderer, tag);
 }
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 } // namespace Msp
index 4dce63b99870b96aa5c52cdb5296fcdba2311344..fe3d6d6b82f57de8a920ea01c326ccde6c817748 100644 (file)
@@ -1,26 +1,26 @@
-#ifndef MSP_GL_STEREOVIEW_H_
-#define MSP_GL_STEREOVIEW_H_
+#ifndef MSP_VR_STEREOVIEW_H_
+#define MSP_VR_STEREOVIEW_H_
 
 #include <msp/geometry/angle.h>
 
 #include <msp/geometry/angle.h>
-#include "camera.h"
-#include "framebuffer.h"
-#include "renderable.h"
-#include "renderbuffer.h"
-#include "texture2d.h"
+#include <msp/gl/camera.h>
+#include <msp/gl/framebuffer.h>
+#include <msp/gl/renderable.h>
+#include <msp/gl/renderbuffer.h>
+#include <msp/gl/texture2d.h>
 
 namespace Msp {
 
 namespace Msp {
-namespace GL {
+namespace VR {
 
 class StereoCombiner;
 
 
 class StereoCombiner;
 
-class StereoView: public Renderable
+class StereoView: public GL::Renderable
 {
 private:
        struct RenderTarget
        {
 {
 private:
        struct RenderTarget
        {
-               Framebuffer fbo;
-               Texture2D color;
-               Renderbuffer depth;
+               GL::Framebuffer fbo;
+               GL::Texture2D color;
+               GL::Renderbuffer depth;
 
                RenderTarget(unsigned, unsigned);
        };
 
                RenderTarget(unsigned, unsigned);
        };
@@ -35,28 +35,28 @@ private:
 
        struct Eye
        {
 
        struct Eye
        {
-               mutable Camera camera;
+               mutable GL::Camera camera;
                RenderTarget *target;
 
                Eye();
 
                void create_target(unsigned, unsigned);
                RenderTarget *target;
 
                Eye();
 
                void create_target(unsigned, unsigned);
-               void setup_frame(const Camera &, const Vector3 &, const EyeParams &) const;
-               void render(const Renderable &, const Tag &) const;
+               void setup_frame(const GL::Camera &, const GL::Vector3 &, const EyeParams &) const;
+               void render(const GL::Renderable &, const GL::Tag &) const;
        };
 
        unsigned width;
        unsigned height;
        };
 
        unsigned width;
        unsigned height;
-       const Camera &base_camera;
-       const Renderable &renderable;
+       const GL::Camera &base_camera;
+       const GL::Renderable &renderable;
        const StereoCombiner *combiner;
        Eye left;
        Eye right;
        float eye_spacing;
        const StereoCombiner *combiner;
        Eye left;
        Eye right;
        float eye_spacing;
-       mutable Vector3 offset_axis;
+       mutable GL::Vector3 offset_axis;
 
 public:
 
 public:
-       StereoView(unsigned, unsigned, const Camera &, const Renderable &, const StereoCombiner &);
+       StereoView(unsigned, unsigned, const GL::Camera &, const GL::Renderable &, const StereoCombiner &);
 
        void set_combiner(const StereoCombiner &);
        void set_eye_spacing(float);
 
        void set_combiner(const StereoCombiner &);
        void set_eye_spacing(float);
@@ -64,11 +64,11 @@ public:
        virtual void setup_frame() const;
        virtual void finish_frame() const;
 
        virtual void setup_frame() const;
        virtual void finish_frame() const;
 
-       virtual void render(const Tag & = Tag()) const;
-       virtual void render(Renderer &, const Tag & = Tag()) const;
+       virtual void render(const GL::Tag & = GL::Tag()) const;
+       virtual void render(GL::Renderer &, const GL::Tag & = GL::Tag()) const;
 };
 
 };
 
-} // namespace GL
+} // namespace VR
 } // namespace Msp
 
 #endif
 } // namespace Msp
 
 #endif