]>
Dogcows Code - chaz/yoink/blob - src/moof/video.hh
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
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.
8 *****************************************************************************/
10 #ifndef _MOOF_VIDEO_HH_
11 #define _MOOF_VIDEO_HH_
15 #include <boost/shared_ptr.hpp>
18 #include <moof/backend.hh>
19 #include <moof/math.hh>
20 #include <moof/timer.hh>
25 * Classes for managing a video context.
31 // forward declarations
35 typedef boost::shared_ptr
<video
> video_ptr
;
43 int color_buffer
[4]; // rgba
45 bool is_double_buffer
;
48 int accumulator_buffer
[4]; // rgba
52 bool is_hardware_only
;
53 int mode
[3]; // width, height, bpp
56 bool is_cursor_visible
;
57 bool is_cursor_captured
;
60 attributes(const settings
& settings
);
69 static video_ptr
alloc(const attributes
& attribs
)
71 return video_ptr(new video(attribs
));
74 explicit video(const std::string
& caption
= "Moof!!");
75 explicit video(const class attributes
& attribs
);
76 explicit video(const std::string
& caption
,
77 const class attributes
& attribs
);
80 class attributes
attributes() const;
82 void mode(const int mode
[3]);
84 void resize(int width
, int height
);
87 void caption(const std::string
& caption
);
88 const std::string
& caption() const;
90 void fullscreen(bool full
);
91 bool fullscreen() const;
92 void toggle_fullscreen();
94 void resizable(bool is_resizable
);
95 bool resizable() const;
96 void toggle_resizable();
98 void cursor_visible(bool is_cursor_visible
);
99 bool cursor_visible() const;
100 void toggle_cursor_visible();
102 void cursor_captured(bool is_cursor_captured
);
103 bool cursor_captured() const;
104 void toggle_cursor_captured();
107 * Swap the video buffers if double-buffered.
109 void swap(scalar t
= timer::ticks());
112 * Make this video context the current context which will be effected
113 * by future draw commands.
115 void make_current() const;
118 * Get the current video context where draw commands are sent.
120 static video
& current()
126 * Get whether or not a video context is in place and is ready to
127 * received drawing commands.
135 * Get the width of the video display.
136 * \return The pixel width.
141 * Get the height of the video display.
142 * \return The pixel height.
146 void show_fps(bool show
)
149 fps_accumulator_
= SCALAR(0.0);
151 last_swap_
= SCALAR(0.0);
154 bool show_fps() const
163 void recreate_context();
164 void set_opengl_attributes();
166 // TODO: this implementation is not well hidden
168 SDL_Surface
* context_
;
170 class attributes attributes_
;
172 std::string caption_
;
173 scalar fps_accumulator_
;
177 static video
* current_
;
183 #endif // _MOOF_VIDEO_HH_
This page took 0.038443 seconds and 4 git commands to generate.