-/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+/*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
**] All rights reserved.
*
-* vi:ts=4 sw=4 tw=75
-*
* Distributable under the terms and conditions of the 2-clause BSD license;
* see the file COPYING for a complete text of the license.
*
-**************************************************************************/
+*****************************************************************************/
#ifndef _MOOF_VIDEO_HH_
#define _MOOF_VIDEO_HH_
-/**
- * \file video.hh
- * Classes for managing a video context.
- */
-
#include <string>
#include <boost/shared_ptr.hpp>
#include <moof/timer.hh>
+/**
+ * \file video.hh
+ * Classes for managing a video context.
+ */
+
namespace moof {
+// forward declarations
class settings;
class video;
typedef boost::shared_ptr<video> video_ptr;
-
class video
{
public:
struct attributes
{
- int color_buffer[4]; // rgba
- int frame_buffer;
- bool is_double_buffer;
- int depth_buffer;
- int stencil_buffer;
- int accumulator_buffer[4]; // rgba
- bool is_stereo;
- int multisample_buffers;
- int multisample_samples;
- bool is_swap_control;
- bool is_hardware_only;
- int mode[3]; // width, height, bpp
- bool is_fullscreen;
- bool is_resizable;
- bool is_cursor_visible;
- bool is_cursor_captured;
+ int color_buffer[4]; // rgba
+ int frame_buffer;
+ bool is_double_buffer;
+ int depth_buffer;
+ int stencil_buffer;
+ int accumulator_buffer[4]; // rgba
+ bool is_stereo;
+ int multisample_buffers;
+ int multisample_samples;
+ bool is_swap_control;
+ bool is_hardware_only;
+ int mode[3]; // width, height, bpp
+ bool is_fullscreen;
+ bool is_resizable;
+ bool is_cursor_visible;
+ bool is_cursor_captured;
attributes();
attributes(const settings& settings);
void init();
- backend mBackend;
+ backend backend_;
};
-
static video_ptr alloc(const attributes& attribs)
{
return video_ptr(new video(attribs));
explicit video(const std::string& caption = "Moof!!");
explicit video(const class attributes& attribs);
explicit video(const std::string& caption,
- const class attributes& attribs);
+ const class attributes& attribs);
~video();
class attributes attributes() const;
bool cursor_captured() const;
void toggle_cursor_captured();
-
/**
* Swap the video buffers if double-buffered.
*/
void swap(scalar t = timer::ticks());
-
/**
* Make this video context the current context which will be effected
* by future draw commands.
return current_;
}
-
/**
* Get the width of the video display.
* \return The pixel width.
*/
int height() const;
-
void show_fps(bool show)
{
show_fps_ = show;
return show_fps_;
}
-
private:
void init();
// TODO: this implementation is not well hidden
SDL_Surface* context_;
- int flags_;
+ int flags_;
class attributes attributes_;
- bool show_fps_;
- std::string caption_;
- scalar fps_accumulator_;
- int fps_counter_;
- scalar last_swap_;
+ bool show_fps_;
+ std::string caption_;
+ scalar fps_accumulator_;
+ int fps_counter_;
+ scalar last_swap_;
static video* current_;
};