#include <video_sdl.h>
Inheritance diagram for video_sdl:
Public Methods | |
video_sdl (void) | |
Default Constructor. | |
virtual | ~video_sdl (void) |
Destructor. | |
virtual bool | init (unsigned int w, unsigned int h, unsigned int bpp, bool fs) |
Initalizes the video system. More... | |
virtual void | set_title (const std::string &title) |
Sets the title of the window. | |
virtual void | resize (unsigned int width, unsigned int height) |
Resizes the window to width by height. | |
virtual void | start_frame (void) |
Starts a video frame. More... | |
virtual void | end_frame (void) |
Ends a video frame. More... | |
virtual void | toggle_fullscreen (void) |
Toggles fullscreen mode. | |
virtual void | shutdown (void) |
Shuts down the video system. More... | |
unsigned int | get_width (void) const |
Returns the width of the video surface. | |
unsigned int | get_height (void) const |
Returns the height of the video surface. | |
bool | error (void) const |
Returns true if an error has occurred. | |
std::string | get_error (void) |
Returns the error message. | |
double | get_fps (void) const |
Returns the current frames per second. More... | |
double | get_average_fps (void) const |
Returns the current frames per second. More... | |
double | get_elapsed (void) const |
Returns how much time (in seconds) elapsed since the last frame. | |
bool | get_2d (void) const |
Returns true if we are in 2d mode. | |
void | enable_2d (void) |
Enables 2d mode. | |
void | disable_2d (void) |
Disables 2d mode. | |
void | render_string (real_t &x, real_t &y, const gl::ttf *font, real_t size, const std::string &text) |
Renders the string text to the screen. More... | |
void | render_shadowed_string (real_t &x, real_t &y, const gl::ttf *font, real_t size, real_t shadow_offset, const std::string &text) |
Renders the string text to the screen with a shadow. More... | |
void | render_image (const rectf &rect, const gl::texture &texture) |
Render a texture to screen. More... | |
Protected Methods | |
void | clear_error (void) |
Clears the internal error state. | |
void | set_error (const std::string &msg) |
Sets the internal error state. | |
Protected Attributes | |
SDL_Surface * | m_screen |
Main SDL video surface. | |
bool | m_shutdown |
true if video system has been properly shutdown. | |
unsigned int | m_width |
Video surface width. | |
unsigned int | m_height |
Video surface height. | |
bool | m_fullscreen |
true if in fullscreen mode. | |
unsigned int | m_bpp |
Bits per pixel. | |
bool | m_error |
If an error has occurred. | |
std::string | m_error_msg |
clocker | m_clock |
Video system clock. | |
int | m_2d_enabled |
How many time enable_2d( ) has been called without calling disable_2d( ). | |
double | m_fps |
Instantanious frames per second. | |
double | m_avg_fps |
Frames per second averaged over the last 500 ms. | |
double | m_fps_sum |
Sum of fps over last 500ms. | |
unsigned int | m_frame_count |
Elapsed frames since last avg fps calculation. |
SDL implementation of video_base.
Definition at line 15 of file video_sdl.h.
|
Ends a video frame. This method should be called at the end of each frame. Implements video_base. Definition at line 109 of file video_sdl.cpp. |
|
Returns the current frames per second. This stat is updated every 500ms. Definition at line 131 of file video_base.h. References video_base::m_avg_fps. |
|
Returns the current frames per second. This stat is updated every frame. Definition at line 123 of file video_base.h. References video_base::m_fps. |
|
Initalizes the video system.
Creates a video surface w pixels wide by h pixels in height. If fs is set to
Implements video_base. Definition at line 26 of file video_sdl.cpp. References gl::init, video_base::m_bpp, video_base::m_clock, video_base::m_fullscreen, video_base::m_height, m_screen, video_base::m_width, clocker::reset, and video_base::set_error. |
|
Render a texture to screen. rect is expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the image will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen.
Definition at line 102 of file video_base.cpp. References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, gl::render_image, and rectangle::scale. |
|
Renders the string text to the screen with a shadow. x and y are expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the font text will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen. Both x and y will be updated with the last pixel drawn to the screen. This pixel is the upper right hand corner of the last character in the string and is expressed in the 1024x768 virtual window coordinate system.
Definition at line 44 of file video_base.cpp. References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, and gl::ttf::render_string. |
|
Renders the string text to the screen. x and y are expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the font text will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen. Both x and y will be updated with the last pixel drawn to the screen. This pixel is the upper right hand corner of the last character in the string and is expressed in the 1024x768 virtual window coordinate system.
Definition at line 9 of file video_base.cpp. References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, and gl::ttf::render_string. |
|
Shuts down the video system. This method should be called to release the video system back to the operating system. Implements video_base. Definition at line 130 of file video_sdl.cpp. References m_shutdown. Referenced by ~video_sdl. |
|
Starts a video frame. This method should be called at the beginning of each frame. Implements video_base. Definition at line 84 of file video_sdl.cpp. References clocker::elapsed, video_base::m_avg_fps, video_base::m_clock, video_base::m_fps, video_base::m_fps_sum, video_base::m_frame_count, and clocker::update. |