]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Video.cc
extreme refactoring
[chaz/yoink] / src / Moof / Video.cc
similarity index 72%
rename from src/video.cc
rename to src/Moof/Video.cc
index 7ad8efcf295dd7b9440c723b2f5bf535a26cf813..c41517e51c87601ff96bd25f1c63ba3e83dcfcb1 100644 (file)
 
 #include <stdexcept>
 
 
 #include <stdexcept>
 
-#include "serializable.hh"
-#include "settings.hh"
-#include "dispatcher.hh"
+#include "Dispatcher.hh"
+#include "Serializable.hh"
+#include "Settings.hh"
+#include "Video.hh"
 
 
-#include "video.hh"
 
 
+namespace Mf {
 
 
-namespace dc {
 
 
-
-video::video()
+Video::Video()
 {
        std::string caption;
 {
        std::string caption;
-       if (settings::instance().get("video.caption", caption))
+       if (Settings::instance().get("video.caption", caption))
        {
                init(attribs_, caption);
        }
        {
                init(attribs_, caption);
        }
@@ -51,15 +50,15 @@ video::video()
        }
 }
 
        }
 }
 
-video::video(const attributes& attribs, const std::string& caption)
+Video::Video(const Attributes& attribs, const std::string& caption)
 {
        init(attribs, caption);
 }
 
 {
        init(attribs, caption);
 }
 
-video::video(const attributes& attribs)
+Video::Video(const Attributes& attribs)
 {
        std::string caption;
 {
        std::string caption;
-       if (settings::instance().get("video.caption", caption))
+       if (Settings::instance().get("video.caption", caption))
        {
                init(attribs, caption);
        }
        {
                init(attribs, caption);
        }
@@ -69,12 +68,12 @@ video::video(const attributes& attribs)
        }
 }
 
        }
 }
 
-video::video(const std::string& caption)
+Video::Video(const std::string& caption)
 {
        init(attribs_, caption);
 }
 
 {
        init(attribs_, caption);
 }
 
-void video::init(const attributes& attribs, const std::string& caption)
+void Video::init(const Attributes& attribs, const std::string& caption)
 {
        context_ = 0;
        flags_ = 0;
 {
        context_ = 0;
        flags_ = 0;
@@ -89,15 +88,15 @@ void video::init(const attributes& attribs, const std::string& caption)
        setVideoMode(attribs.mode);
 }
 
        setVideoMode(attribs.mode);
 }
 
-void video::recreateContext()
+void Video::recreateContext()
 {
        SDL_FreeSurface(context_);
        context_ = 0;
        setVideoMode(attribs_.mode);
 {
        SDL_FreeSurface(context_);
        context_ = 0;
        setVideoMode(attribs_.mode);
-       dc::dispatcher::instance().dispatch("video.context_recreated");
+       Mf::Dispatcher::instance().dispatch("video.context_recreated");
 }
 
 }
 
-void video::setOpenGLAttributes()
+void Video::setOpenGLAttributes()
 {
        SDL_GL_SetAttribute(SDL_GL_RED_SIZE,           attribs_.colorBuffer[0]);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,         attribs_.colorBuffer[1]);
 {
        SDL_GL_SetAttribute(SDL_GL_RED_SIZE,           attribs_.colorBuffer[0]);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,         attribs_.colorBuffer[1]);
@@ -119,13 +118,13 @@ void video::setOpenGLAttributes()
 }
 
 
 }
 
 
-video::~video()
+Video::~Video()
 {
        SDL_FreeSurface(context_);
 }
 
 
 {
        SDL_FreeSurface(context_);
 }
 
 
-void video::setVideoMode(const long mode[3])
+void Video::setVideoMode(const long mode[3])
 {
        if (mode != attribs_.mode || !context_)
        {
 {
        if (mode != attribs_.mode || !context_)
        {
@@ -140,34 +139,34 @@ void video::setVideoMode(const long mode[3])
                        attribs_.mode[1] = mode[1];
                        attribs_.mode[2] = mode[2];
                }
                        attribs_.mode[1] = mode[1];
                        attribs_.mode[2] = mode[2];
                }
-               else throw std::runtime_error(SDL_GetError());
+               else throw Exception(SDL_GetError());
        }
 }
 
        }
 }
 
-video::attributes video::getAttributes() const
+Video::Attributes Video::getAttributes() const
 {
        return attribs_;
 }
 
 
 {
        return attribs_;
 }
 
 
-void video::resize(int width, int height)
+void Video::resize(int width, int height)
 {
        long mode[] = {width, height, attribs_.mode[2]};
        setVideoMode(mode);
 }
 
 {
        long mode[] = {width, height, attribs_.mode[2]};
        setVideoMode(mode);
 }
 
-bool video::iconify()
+bool Video::iconify()
 {
        return SDL_WM_IconifyWindow();
 }
 
 
 {
        return SDL_WM_IconifyWindow();
 }
 
 
-void video::setCaption(const std::string& caption)
+void Video::setCaption(const std::string& caption)
 {
        SDL_WM_SetCaption(caption.c_str(), 0);
 }
 
 {
        SDL_WM_SetCaption(caption.c_str(), 0);
 }
 
-std::string video::getCaption() const
+std::string Video::getCaption() const
 {
        char* str;
        SDL_WM_GetCaption(&str, 0);
 {
        char* str;
        SDL_WM_GetCaption(&str, 0);
@@ -175,7 +174,7 @@ std::string video::getCaption() const
 }
 
 
 }
 
 
-void video::setFull(bool full)
+void Video::setFull(bool full)
 {
        if (full != isFull() || !context_)
        {
 {
        if (full != isFull() || !context_)
        {
@@ -196,34 +195,34 @@ void video::setFull(bool full)
        }
 }
 
        }
 }
 
-void video::toggleFull()
+void Video::toggleFull()
 {
        setFull(!isFull());
 }
 
 {
        setFull(!isFull());
 }
 
-bool video::isFull() const
+bool Video::isFull() const
 {
        return flags_ & SDL_FULLSCREEN;
 }
 
 
 {
        return flags_ & SDL_FULLSCREEN;
 }
 
 
-void video::setCursorVisible(bool hasCursor)
+void Video::setCursorVisible(bool hasCursor)
 {
        SDL_ShowCursor(hasCursor? SDL_ENABLE : SDL_DISABLE);
 }
 
 {
        SDL_ShowCursor(hasCursor? SDL_ENABLE : SDL_DISABLE);
 }
 
-void video::toggleCursorVisible()
+void Video::toggleCursorVisible()
 {
        setCursorVisible(!isCursorVisible());
 }
 
 {
        setCursorVisible(!isCursorVisible());
 }
 
-bool video::isCursorVisible() const
+bool Video::isCursorVisible() const
 {
        return (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE);
 }
 
 
 {
        return (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE);
 }
 
 
-void video::setResizable(bool resizable)
+void Video::setResizable(bool resizable)
 {
        if (resizable != isResizable() || !context_)
        {
 {
        if (resizable != isResizable() || !context_)
        {
@@ -240,46 +239,46 @@ void video::setResizable(bool resizable)
        }
 }
 
        }
 }
 
-void video::toggleResizable()
+void Video::toggleResizable()
 {
        setResizable(!isResizable());
 }
 
 {
        setResizable(!isResizable());
 }
 
-bool video::isResizable() const
+bool Video::isResizable() const
 {
        return flags_ & SDL_RESIZABLE;
 }
 
 
 {
        return flags_ & SDL_RESIZABLE;
 }
 
 
-bool video::isCursorGrab() const
+bool Video::isCursorGrab() const
 {
        return (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
 }
 
 {
        return (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
 }
 
-void video::toggleCursorGrab()
+void Video::toggleCursorGrab()
 {
        setCursorGrab(!isCursorGrab());
 }
 
 {
        setCursorGrab(!isCursorGrab());
 }
 
-void video::setCursorGrab(bool cursorGrab)
+void Video::setCursorGrab(bool cursorGrab)
 {
        SDL_WM_GrabInput(cursorGrab? SDL_GRAB_ON : SDL_GRAB_OFF);
 }
 
 
 {
        SDL_WM_GrabInput(cursorGrab? SDL_GRAB_ON : SDL_GRAB_OFF);
 }
 
 
-void video::makeActive()
+void Video::makeActive()
 {
        // NOP until the day SDL supports more than only one window.
        // Still waiting...
 }
 
 {
        // NOP until the day SDL supports more than only one window.
        // Still waiting...
 }
 
-void video::swap()
+void Video::swap()
 {
        SDL_GL_SwapBuffers();
 }
 
 
 {
        SDL_GL_SwapBuffers();
 }
 
 
-video::attributes::attributes()
+Video::Attributes::Attributes()
 {
        // Set some sane GL and window defaults (see SDL_video.c:217)
        colorBuffer[0] = 3;
 {
        // Set some sane GL and window defaults (see SDL_video.c:217)
        colorBuffer[0] = 3;
@@ -307,45 +306,45 @@ video::attributes::attributes()
        cursorVisible = true;
        cursorGrab = false;
 
        cursorVisible = true;
        cursorGrab = false;
 
-       std::vector<serializable_ptr> colors;
-       settings::instance().get("video.colorbuffers", colors);
+       std::vector<SerializablePtr> colors;
+       Settings::instance().get("video.colorbuffers", colors);
        if (colors.size() > 0) colors[0]->get(colorBuffer[0]);
        if (colors.size() > 1) colors[1]->get(colorBuffer[1]);
        if (colors.size() > 2) colors[2]->get(colorBuffer[2]);
        if (colors.size() > 3) colors[3]->get(colorBuffer[3]);
 
        if (colors.size() > 0) colors[0]->get(colorBuffer[0]);
        if (colors.size() > 1) colors[1]->get(colorBuffer[1]);
        if (colors.size() > 2) colors[2]->get(colorBuffer[2]);
        if (colors.size() > 3) colors[3]->get(colorBuffer[3]);
 
-       settings::instance().get("video.framebuffer", frameBuffer);
-       settings::instance().get("video.doublebuffer", doubleBuffer);
-       settings::instance().get("video.depthbuffer", depthBuffer);
-       settings::instance().get("video.stencilbuffer", stencilBuffer);
+       Settings::instance().get("video.framebuffer", frameBuffer);
+       Settings::instance().get("video.doublebuffer", doubleBuffer);
+       Settings::instance().get("video.depthbuffer", depthBuffer);
+       Settings::instance().get("video.stencilbuffer", stencilBuffer);
 
 
-       std::vector<serializable_ptr> accum;
-       settings::instance().get("video.accumbuffers", accum);
+       std::vector<SerializablePtr> accum;
+       Settings::instance().get("video.accumbuffers", accum);
        if (accum.size() > 0) accum[0]->get(accumBuffer[0]);
        if (accum.size() > 1) accum[1]->get(accumBuffer[1]);
        if (accum.size() > 2) accum[2]->get(accumBuffer[2]);
        if (accum.size() > 3) accum[3]->get(accumBuffer[3]);
 
        if (accum.size() > 0) accum[0]->get(accumBuffer[0]);
        if (accum.size() > 1) accum[1]->get(accumBuffer[1]);
        if (accum.size() > 2) accum[2]->get(accumBuffer[2]);
        if (accum.size() > 3) accum[3]->get(accumBuffer[3]);
 
-       settings::instance().get("video.stereo", stereo);
-       settings::instance().get("video.multiesamplebuffers", multisampleBuffers);
-       settings::instance().get("video.multiesamplesamples", multisampleSamples);
-       settings::instance().get("video.swapcontrol", swapControl);
-       settings::instance().get("video.hardwareonly", hardwareonly);
+       Settings::instance().get("video.stereo", stereo);
+       Settings::instance().get("video.multiesamplebuffers", multisampleBuffers);
+       Settings::instance().get("video.multiesamplesamples", multisampleSamples);
+       Settings::instance().get("video.swapcontrol", swapControl);
+       Settings::instance().get("video.hardwareonly", hardwareonly);
 
 
-       std::vector<serializable_ptr> dimensions;
-       settings::instance().get("video.mode", dimensions);
+       std::vector<SerializablePtr> dimensions;
+       Settings::instance().get("video.mode", dimensions);
        if (dimensions.size() > 0) dimensions[0]->get(mode[0]);
        if (dimensions.size() > 1) dimensions[1]->get(mode[1]);
        if (dimensions.size() > 2) dimensions[2]->get(mode[2]);
 
        if (dimensions.size() > 0) dimensions[0]->get(mode[0]);
        if (dimensions.size() > 1) dimensions[1]->get(mode[1]);
        if (dimensions.size() > 2) dimensions[2]->get(mode[2]);
 
-       settings::instance().get("video.fullscreen", fullscreen);
-       settings::instance().get("video.resizable", resizable);
-       settings::instance().get("video.showcursor", cursorVisible);
-       settings::instance().get("input.grab", cursorGrab);
+       Settings::instance().get("video.fullscreen", fullscreen);
+       Settings::instance().get("video.resizable", resizable);
+       Settings::instance().get("video.showcursor", cursorVisible);
+       Settings::instance().get("input.grab", cursorGrab);
 }
 
 
 }
 
 
-} // namespace dc
+} // namespace Mf
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
This page took 0.029247 seconds and 4 git commands to generate.