]> Dogcows Code - chaz/yoink/blob - src/moof/video.hh
configuration cleanup and bugfixes
[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 /**
16 * \file video.hh
17 * Classes for managing a video context.
18 */
19
20 #include <string>
21
22 #include <boost/shared_ptr.hpp>
23 #include <SDL/SDL.h>
24
25 #include <moof/backend.hh>
26
27
28 namespace moof {
29
30
31 class settings;
32
33 class video;
34 typedef boost::shared_ptr<video> video_ptr;
35
36
37 class video
38 {
39 public:
40
41 struct attributes
42 {
43 int color_buffer[4]; // rgba
44 int frame_buffer;
45 bool is_double_buffer;
46 int depth_buffer;
47 int stencil_buffer;
48 int accumulator_buffer[4]; // rgba
49 bool is_stereo;
50 int multisample_buffers;
51 int multisample_samples;
52 bool is_swap_control;
53 bool is_hardware_only;
54 int mode[3]; // width, height, bpp
55 bool is_fullscreen;
56 bool is_resizable;
57 bool is_cursor_visible;
58 bool is_cursor_captured;
59
60 attributes();
61 attributes(const settings& settings);
62
63 private:
64
65 void init();
66
67 backend mBackend;
68 };
69
70
71 static video_ptr alloc(const attributes& attribs)
72 {
73 return video_ptr(new video(attribs));
74 }
75
76 explicit video(const std::string& caption = "Moof!!");
77 explicit video(const class attributes& attribs);
78 explicit video(const std::string& caption,
79 const class attributes& attribs);
80 ~video();
81
82 class attributes attributes() const;
83
84 void mode(const int mode[3]);
85
86 void resize(int width, int height);
87 bool iconify();
88
89 void caption(const std::string& caption);
90 std::string caption() const;
91
92 void fullscreen(bool full);
93 bool fullscreen() const;
94 void toggle_fullscreen();
95
96 void resizable(bool is_resizable);
97 bool resizable() const;
98 void toggle_resizable();
99
100 void cursor_visible(bool is_cursor_visible);
101 bool cursor_visible() const;
102 void toggle_cursor_visible();
103
104 void cursor_captured(bool is_cursor_captured);
105 bool cursor_captured() const;
106 void toggle_cursor_captured();
107
108
109 /**
110 * Swap the video buffers if double-buffered.
111 */
112 void swap();
113
114
115 /**
116 * Make this video context the current context which will be effected
117 * by future draw commands.
118 */
119 void make_current() const;
120
121 /**
122 * Get the current video context where draw commands are sent.
123 */
124 static video* current()
125 {
126 return current_;
127 }
128
129
130 /**
131 * Get the width of the video display.
132 * \return The pixel width.
133 */
134 int width() const;
135
136 /**
137 * Get the height of the video display.
138 * \return The pixel height.
139 */
140 int height() const;
141
142
143 private:
144
145 void init();
146
147 void recreate_context();
148 void set_opengl_attributes();
149
150 // TODO: this implementation is not well hidden
151
152 SDL_Surface* context_;
153 int flags_;
154 class attributes attributes_;
155
156 static video* current_;
157 };
158
159
160 } // namespace moof
161
162 #endif // _MOOF_VIDEO_HH_
163
This page took 0.035266 seconds and 4 git commands to generate.