]> Dogcows Code - chaz/yoink/blobdiff - src/moof/video.hh
the massive refactoring effort
[chaz/yoink] / src / moof / video.hh
diff --git a/src/moof/video.hh b/src/moof/video.hh
new file mode 100644 (file)
index 0000000..ea331a0
--- /dev/null
@@ -0,0 +1,163 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_VIDEO_HH_
+#define _MOOF_VIDEO_HH_
+
+/**
+ * \file video.hh
+ * Classes for managing a video context.
+ */
+
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+#include <SDL/SDL.h>
+
+#include <moof/backend.hh>
+
+
+namespace moof {
+
+
+class settings;
+
+class video;
+typedef boost::shared_ptr<video> video_ptr;
+
+
+class video
+{
+public:
+
+       struct attributes
+       {
+               int                     color_buffer[4];                // rgba
+               int                     frame_buffer;
+               bool            is_double_buffer;
+               int                     depth_buffer;
+               int                     stencil_buffer;
+               int                     accumulator_buffer[4];  // rgba
+               bool            is_stereo;
+               int                     multisample_buffers;
+               int                     multisample_samples;
+               bool            is_swap_control;
+               bool            is_hardware_only;
+               int                     mode[3];                                // width, height, bpp
+               bool            is_fullscreen;
+               bool            is_resizable;
+               bool            is_cursor_visible;
+               bool            is_cursor_captured;
+
+               attributes();
+               attributes(const settings& settings);
+
+       private:
+
+               void init();
+
+               backend         mBackend;
+       };
+
+
+       static video_ptr alloc(const attributes& attribs)
+       {
+               return video_ptr(new video(attribs));
+       }
+
+       explicit video(const std::string& caption = "Moof!!");
+       explicit video(const class attributes& attribs);
+       explicit video(const std::string& caption,
+                                  const class attributes& attribs);
+       ~video();
+
+       class attributes attributes() const;
+
+       void mode(const int mode[3]);
+
+       void resize(int width, int height);
+       bool iconify();
+
+       void caption(const std::string& caption);
+       std::string caption() const;
+
+       void fullscreen(bool full);
+       bool fullscreen() const;
+       void toggle_fullscreen();
+
+       void resizable(bool is_resizable);
+       bool resizable() const;
+       void toggle_resizable();
+
+       void cursor_visible(bool is_cursor_visible);
+       bool cursor_visible() const;
+       void toggle_cursor_visible();
+
+       void cursor_captured(bool is_cursor_captured);
+       bool cursor_captured() const;
+       void toggle_cursor_captured();
+
+
+       /**
+        * Swap the video buffers if double-buffered.
+        */
+       void swap();
+
+
+       /**
+        * Make this video context the current context which will be effected
+        * by future draw commands.
+        */
+       void make_current() const;
+
+       /**
+        * Get the current video context where draw commands are sent.
+        */
+       static video* current()
+       {
+               return current_;
+       }
+
+
+       /**
+        * Get the width of the video display.
+        * \return The pixel width.
+        */
+       int width() const;
+
+       /**
+        * Get the height of the video display.
+        * \return The pixel height.
+        */
+       int height() const;
+
+
+private:
+
+       void init();
+
+       void recreate_context();
+       void set_opengl_attributes();
+
+       // TODO: this implementation is not well hidden
+
+       SDL_Surface*            context_;
+       int                                     flags_;
+       class attributes        attributes_;
+
+       static video*           current_;
+};
+
+
+} // namespace moof
+
+#endif // _MOOF_VIDEO_HH_
+
This page took 0.025527 seconds and 4 git commands to generate.