]> Dogcows Code - chaz/yoink/blob - src/moof/video.hh
remove some unused stlplus modules
[chaz/yoink] / src / moof / video.hh
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #ifndef _MOOF_VIDEO_HH_
11 #define _MOOF_VIDEO_HH_
12
13 /**
14 * \file video.hh
15 * Classes for managing a video context.
16 */
17
18 #include <string>
19
20 #include <boost/shared_ptr.hpp>
21 #include <SDL/SDL.h>
22
23 #include <moof/backend.hh>
24 #include <moof/math.hh>
25 #include <moof/timer.hh>
26
27
28 namespace moof {
29
30
31 // forward declarations
32 class settings;
33
34 class video;
35 typedef boost::shared_ptr<video> video_ptr;
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 backend_;
68 };
69
70 static video_ptr alloc(const attributes& attribs)
71 {
72 return video_ptr(new video(attribs));
73 }
74
75 explicit video(const std::string& caption = "Moof!!");
76 explicit video(const class attributes& attribs);
77 explicit video(const std::string& caption,
78 const class attributes& attribs);
79 ~video();
80
81 class attributes attributes() const;
82
83 void mode(const int mode[3]);
84
85 void resize(int width, int height);
86 bool iconify();
87
88 void caption(const std::string& caption);
89 const std::string& caption() const;
90
91 void fullscreen(bool full);
92 bool fullscreen() const;
93 void toggle_fullscreen();
94
95 void resizable(bool is_resizable);
96 bool resizable() const;
97 void toggle_resizable();
98
99 void cursor_visible(bool is_cursor_visible);
100 bool cursor_visible() const;
101 void toggle_cursor_visible();
102
103 void cursor_captured(bool is_cursor_captured);
104 bool cursor_captured() const;
105 void toggle_cursor_captured();
106
107 /**
108 * Swap the video buffers if double-buffered.
109 */
110 void swap(scalar t = timer::ticks());
111
112 /**
113 * Make this video context the current context which will be effected
114 * by future draw commands.
115 */
116 void make_current() const;
117
118 /**
119 * Get the current video context where draw commands are sent.
120 */
121 static video* current()
122 {
123 return current_;
124 }
125
126 /**
127 * Get the width of the video display.
128 * \return The pixel width.
129 */
130 int width() const;
131
132 /**
133 * Get the height of the video display.
134 * \return The pixel height.
135 */
136 int height() const;
137
138 void show_fps(bool show)
139 {
140 show_fps_ = show;
141 fps_accumulator_ = SCALAR(0.0);
142 fps_counter_ = 0;
143 last_swap_ = SCALAR(0.0);
144 }
145
146 bool show_fps() const
147 {
148 return show_fps_;
149 }
150
151 private:
152
153 void init();
154
155 void recreate_context();
156 void set_opengl_attributes();
157
158 // TODO: this implementation is not well hidden
159
160 SDL_Surface* context_;
161 int flags_;
162 class attributes attributes_;
163 bool show_fps_;
164 std::string caption_;
165 scalar fps_accumulator_;
166 int fps_counter_;
167 scalar last_swap_;
168
169 static video* current_;
170 };
171
172
173 } // namespace moof
174
175 #endif // _MOOF_VIDEO_HH_
176
This page took 0.046965 seconds and 5 git commands to generate.