Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

video_sdl Class Reference

The main SDL video surface. More...

#include <video_sdl.h>

Inheritance diagram for video_sdl:

Inheritance graph
[legend]
Collaboration diagram for video_sdl:

Collaboration graph
[legend]
List of all members.

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.


Detailed Description

The main SDL video surface.

SDL implementation of video_base.

Definition at line 15 of file video_sdl.h.


Member Function Documentation

void video_sdl::end_frame void    [virtual]
 

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.

double video_base::get_average_fps void    const [inline, inherited]
 

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.

double video_base::get_fps void    const [inline, inherited]
 

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.

bool video_sdl::init unsigned int    w,
unsigned int    h,
unsigned int    bpp,
bool    fs
[virtual]
 

Initalizes the video system.

Creates a video surface w pixels wide by h pixels in height. If fs is set to true, the surface will be composed of the entire screen, otherwise the surface will consist of a single window.

Parameters:
w  Width of surface.
h  Height of surface.
bpp  Bits per pixel of surface (generally 16, 24, or 32).
fs  Fullscreen.
Returns:
true if the video system was successfully initialized.

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.

void video_base::render_image const rectf &    rect,
const gl::texture   texture
[inherited]
 

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.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.

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.

void video_base::render_shadowed_string real_t   x,
real_t   y,
const gl::ttf   font,
real_t    size,
real_t    shadow_offset,
const std::string &    text
[inherited]
 

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.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.
Parameters:
x  x coordinate of where to render the screen. x is updated with the final rendering position.
y  y coordinate of where to render the screen. y is updated with the final rendering position.
font  The font to be used to render the string.
size  Height of the largest glyph in font. Measured in pixels.
shadow_offset  The number of pixels to offset the shadow.
text  The string to render.

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.

void video_base::render_string real_t   x,
real_t   y,
const gl::ttf   font,
real_t    size,
const std::string &    text
[inherited]
 

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.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.
Parameters:
x  x coordinate of where to render the screen. x is updated with the final rendering position.
y  y coordinate of where to render the screen. y is updated with the final rendering position.
font  The font to be used to render the string.
size  Height of the largest glyph in font. Measured in pixels.
text  The string to render.

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.

void video_sdl::shutdown void    [virtual]
 

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.

void video_sdl::start_frame void    [virtual]
 

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.


Generated on Tue Feb 11 18:49:46 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002