]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Video.hh
fixed layer bugs; generalized octree
[chaz/yoink] / src / Moof / Video.hh
index a76dca268ef052f136124bc425769d6f65a32f72..5f56f9e1d33e103ac0bf912b7f6584d0e45b516d 100644 (file)
 
 #include <SDL/SDL.h>
 
+#include <Moof/Exception.hh>
+
 
 namespace Mf {
 
 
-class Video
+class Video;
+typedef boost::shared_ptr<Video> VideoP;
+
+
+struct Video
 {
-public:
        struct Attributes
        {
                // OpenGL attributes
-               long    colorBuffer[4]; // rgba
-               long    frameBuffer;
-               bool    doubleBuffer;
-               long    depthBuffer;
-               long    stencilBuffer;
-               long    accumBuffer[4]; // rgba
-               bool    stereo;
-               long    multisampleBuffers;
-               long    multisampleSamples;
-               bool    swapControl;
-               bool    hardwareonly;
+               long            colorBuffer[4]; // rgba
+               long            frameBuffer;
+               bool            doubleBuffer;
+               long            depthBuffer;
+               long            stencilBuffer;
+               long            accumBuffer[4]; // rgba
+               bool            stereo;
+               long            multisampleBuffers;
+               long            multisampleSamples;
+               bool            swapControl;
+               bool            hardwareonly;
 
                // Window attributes
-               long    mode[3];                // width, height, bpp
-               bool    fullscreen;
-               bool    resizable;
-               bool    cursorVisible;
-               bool    cursorGrab;
+               std::string     caption;
+               std::string     icon;
+               long            mode[3];                // width, height, bpp
+               bool            fullscreen;
+               bool            resizable;
+               bool            cursorVisible;
+               bool            cursorGrab;
 
                Attributes();
        };
 
+
+private:
+
+       void init(const Attributes& attribs);
+
+       void recreateContext();
+       void setOpenGLAttributes();
+
+       void setIcon();
+
+       SDL_Surface* context_;
+       unsigned flags_;
+       Attributes attribs_;
+
+public:
+
+       static VideoP alloc(const std::string& caption, const std::string& icon)
+       {
+               return VideoP(new Video(caption, icon));
+       }
+
        Video();
-       Video(const Attributes& attribs);
-       Video(const Attributes& attribs, const std::string& caption);
-       Video(const std::string& caption);
+       explicit Video(const Attributes& attribs);
+       explicit Video(const std::string& caption, const std::string& icon);
        ~Video();
 
        void setVideoMode(const long mode[3]);
@@ -101,25 +128,22 @@ public:
        void makeActive();
        void swap();
 
+       int getWidth() const;
+       int getHeight() const;
 
-       struct Exception : public std::runtime_error
-       {
-               explicit Exception(const std::string& what_arg) :
-                       std::runtime_error(what_arg) {}
-       };
 
-private:
-       void init(const Attributes& attribs, const std::string& caption);
-       void recreateContext();
-       void setOpenGLAttributes();
+       struct Exception : public Mf::Exception
+       {
+               explicit Exception(unsigned error) :
+                       Mf::Exception(error) {}
 
-       SDL_Surface* context_;
-       unsigned flags_;
-       Attributes attribs_;
+               void raise()
+               {
+                       throw *this;
+               }
+       };
 };
 
-typedef boost::shared_ptr<Video> VideoPtr;
-
 
 } // namespace Mf
 
This page took 0.021508 seconds and 4 git commands to generate.