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