]> Dogcows Code - chaz/yoink/blob - src/Moof/Video.hh
9b1a092332203b3e31291109413cb31e6abaa8bf
[chaz/yoink] / src / Moof / Video.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_VIDEO_HH_
13 #define _MOOF_VIDEO_HH_
14
15 #include <string>
16
17 #include <boost/shared_ptr.hpp>
18 #include <SDL/SDL.h>
19
20 #include <Moof/Core.hh>
21
22
23 namespace Mf {
24
25
26 class Video;
27 typedef boost::shared_ptr<Video> VideoP;
28
29
30 class Video
31 {
32 public:
33
34 struct Attributes
35 {
36 // OpenGL attributes
37 long colorBuffer[4]; // rgba
38 long frameBuffer;
39 bool doubleBuffer;
40 long depthBuffer;
41 long stencilBuffer;
42 long accumBuffer[4]; // rgba
43 bool stereo;
44 long multisampleBuffers;
45 long multisampleSamples;
46 bool swapControl;
47 bool hardwareOnly;
48
49 // Window attributes
50 std::string caption;
51 std::string icon;
52 long mode[3]; // width, height, bpp
53 bool fullscreen;
54 bool resizable;
55 bool cursorVisible;
56 bool cursorGrab;
57
58 Attributes();
59
60 private:
61
62 Backend mBackend;
63
64 };
65
66
67 static VideoP alloc(const std::string& caption,
68 const std::string& icon)
69 {
70 return VideoP(new Video(caption, icon));
71 }
72
73 Video();
74 explicit Video(const Attributes& attribs);
75 Video(const std::string& caption, const std::string& icon);
76 ~Video();
77
78 void setVideoMode(const long mode[3]);
79 Attributes getAttributes() const;
80
81 void resize(int width, int height);
82 bool iconify();
83
84 void setCaption(const std::string& caption);
85 std::string getCaption() const;
86
87 const std::string& getIcon() const;
88
89 void setFull(bool full);
90 void toggleFull();
91 bool isFull() const;
92
93 void setCursorVisible(bool hasCursor);
94 void toggleCursorVisible();
95 bool isCursorVisible() const;
96
97 void setResizable(bool resizable);
98 void toggleResizable();
99 bool isResizable() const;
100
101 void setCursorGrab(bool cursorGrab);
102 void toggleCursorGrab();
103 bool isCursorGrab() const;
104
105 void swap();
106
107 int getWidth() const;
108 int getHeight() const;
109
110 private:
111
112 void init();
113
114 void recreateContext();
115 void setOpenGLAttributes();
116
117 void setIcon();
118
119 // TODO this implementation should be hidden
120
121 SDL_Surface* mContext;
122 unsigned mFlags;
123 Attributes mAttribs;
124 };
125
126
127 extern Video* video;
128
129
130 } // namespace Mf
131
132 #endif // _MOOF_VIDEO_HH_
133
This page took 0.035831 seconds and 3 git commands to generate.