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