From 5244110fa8d347b8539f4fcff1bea729eecc2027 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 13 Sep 2013 16:22:55 +0300 Subject: [PATCH] Rename to mspvr --- source/oculusriftcombiner.cpp | 20 ++++++++-------- source/oculusriftcombiner.h | 24 +++++++++---------- source/sidebysidecombiner.cpp | 20 ++++++++-------- source/sidebysidecombiner.h | 24 +++++++++---------- source/stereocombiner.cpp | 4 ++-- source/stereocombiner.h | 13 +++++------ source/stereoview.cpp | 32 ++++++++++++------------- source/stereoview.h | 44 +++++++++++++++++------------------ 8 files changed, 90 insertions(+), 91 deletions(-) diff --git a/source/oculusriftcombiner.cpp b/source/oculusriftcombiner.cpp index 9d985d9..771f3b8 100644 --- a/source/oculusriftcombiner.cpp +++ b/source/oculusriftcombiner.cpp @@ -1,7 +1,7 @@ #include -#include "meshbuilder.h" +#include +#include #include "oculusriftcombiner.h" -#include "texture2d.h" using namespace std; @@ -41,10 +41,10 @@ const char fs_source[] = } namespace Msp { -namespace GL { +namespace VR { OculusRiftCombiner::OculusRiftCombiner(): - mesh(VERTEX2), + mesh(GL::VERTEX2), 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); - 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); @@ -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(); @@ -166,5 +166,5 @@ void OculusRiftCombiner::render(const Texture2D &left, const Texture2D &right) c mesh.draw(); } -} // namespace GL +} // namespace VR } // namespace Msp diff --git a/source/oculusriftcombiner.h b/source/oculusriftcombiner.h index ede2fe9..a204c3e 100644 --- a/source/oculusriftcombiner.h +++ b/source/oculusriftcombiner.h @@ -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 +#include +#include #include "stereocombiner.h" namespace Msp { -namespace GL { +namespace VR { /** 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: - 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; @@ -41,10 +41,10 @@ private: 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 diff --git a/source/sidebysidecombiner.cpp b/source/sidebysidecombiner.cpp index b9d1d89..213b544 100644 --- a/source/sidebysidecombiner.cpp +++ b/source/sidebysidecombiner.cpp @@ -1,6 +1,6 @@ -#include "meshbuilder.h" +#include +#include #include "sidebysidecombiner.h" -#include "texture2d.h" namespace { @@ -24,10 +24,10 @@ const char fs_source[] = } namespace Msp { -namespace GL { +namespace VR { SideBySideCombiner::SideBySideCombiner(bool c): - mesh(VERTEX2), + mesh(GL::VERTEX2), shprog(vs_source, fs_source) { width_div = 2; @@ -37,8 +37,8 @@ SideBySideCombiner::SideBySideCombiner(bool 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); @@ -54,11 +54,11 @@ void SideBySideCombiner::set_cross_eyed(bool c) 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(); @@ -67,5 +67,5 @@ void SideBySideCombiner::render(const Texture2D &left, const Texture2D &right) c mesh.draw(); } -} // namespace GL +} // namespace VR } // namespace Msp diff --git a/source/sidebysidecombiner.h b/source/sidebysidecombiner.h index f6ec593..52eda28 100644 --- a/source/sidebysidecombiner.h +++ b/source/sidebysidecombiner.h @@ -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 +#include +#include #include "stereocombiner.h" namespace Msp { -namespace GL { +namespace VR { 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: @@ -23,10 +23,10 @@ public: 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 diff --git a/source/stereocombiner.cpp b/source/stereocombiner.cpp index ba71818..54ab3e3 100644 --- a/source/stereocombiner.cpp +++ b/source/stereocombiner.cpp @@ -1,7 +1,7 @@ #include "stereocombiner.h" namespace Msp { -namespace GL { +namespace VR { StereoCombiner::StereoCombiner(): width_div(1), @@ -10,5 +10,5 @@ StereoCombiner::StereoCombiner(): oversize(1.0f) { } -} // namespace GL +} // namespace VR } // namespace Msp diff --git a/source/stereocombiner.h b/source/stereocombiner.h index 5fb8dec..f078df7 100644 --- a/source/stereocombiner.h +++ b/source/stereocombiner.h @@ -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 +#include namespace Msp { -namespace GL { - -class Texture2D; +namespace VR { class StereoCombiner { @@ -27,10 +26,10 @@ public: const Geometry::Angle &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 diff --git a/source/stereoview.cpp b/source/stereoview.cpp index 53c6445..02c60ac 100644 --- a/source/stereoview.cpp +++ b/source/stereoview.cpp @@ -1,13 +1,13 @@ -#include "renderer.h" +#include #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), @@ -60,7 +60,7 @@ void StereoView::finish_frame() const renderable.finish_frame(); } -void StereoView::render(const Tag &tag) const +void StereoView::render(const GL::Tag &tag) const { setup_frame(); left.render(renderable, tag); @@ -69,7 +69,7 @@ void StereoView::render(const Tag &tag) const 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); @@ -78,13 +78,13 @@ void StereoView::render(Renderer &renderer, const Tag &tag) const 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); } -void StereoView::Eye::setup_frame(const Camera &base_camera, const Vector3 &offset, const EyeParams ¶ms) const +void StereoView::Eye::setup_frame(const GL::Camera &base_camera, const GL::Vector3 &offset, const EyeParams ¶ms) const { 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); } -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); } -} // namespace GL +} // namespace VR } // namespace Msp diff --git a/source/stereoview.h b/source/stereoview.h index 4dce63b..fe3d6d6 100644 --- a/source/stereoview.h +++ b/source/stereoview.h @@ -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 -#include "camera.h" -#include "framebuffer.h" -#include "renderable.h" -#include "renderbuffer.h" -#include "texture2d.h" +#include +#include +#include +#include +#include namespace Msp { -namespace GL { +namespace VR { class StereoCombiner; -class StereoView: public Renderable +class StereoView: public GL::Renderable { private: struct RenderTarget { - Framebuffer fbo; - Texture2D color; - Renderbuffer depth; + GL::Framebuffer fbo; + GL::Texture2D color; + GL::Renderbuffer depth; RenderTarget(unsigned, unsigned); }; @@ -35,28 +35,28 @@ private: struct Eye { - mutable Camera camera; + mutable GL::Camera camera; 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; - 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; - mutable Vector3 offset_axis; + mutable GL::Vector3 offset_axis; 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); @@ -64,11 +64,11 @@ public: 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 -- 2.43.0