SDLWindow Class Reference
[C++ Wrapper for SDL]

Manage SDL Window.Manage creation of a SDL Window and collect its events into Input class. More...

#include <SDLWindow.hh>

List of all members.

Public Member Functions

InputgetInput ()
 Get mouse and keyboard current state.
VirtualSurfacegetScreen ()
 Get the root surface, having the height and width of the window.
bool isFullScreen () const
 Check if the window is in fullscreen mode.
void setFullScreen (bool enable)
 Set the fullscreen mode.
int getFps () const
 Get the number of frame per second (typically between 5 and 100 fps).
bool isInitialized ()
 Check if the window was already initialized.
void init (void *conf)
 Initialize all the SDL stuff, or reintialize windows with a new set of values.
void clearScreen ()
 Fill the screen with black.
bool processOneFrame (bool events_only=false)
 Update SDL events, update screen (and all his children), and print one frame on the screen.

Detailed Description

Manage SDL Window.

Manage creation of a SDL Window and collect its events into Input class.

There could only be one instance of this class at one time. It contains (single across the program) instances of:

Here is a simple example of how to use it:

 int run_win(xml::XMLConfig* xml)
 {
   SDLWindow win(xml);
   win.init();
   VirtualSurface& screen = win.getScreen();
   // Do something with screen, like adding sprites.
   while (true) {
     Input& inp = win.getInput();
     // Do something, this is your main loop!
     // You can fetch mouse pos/keyboard state into 'inp'.
     if (win.processOneFrame())
       break;
   }
 }

Member Function Documentation

int SDLWindow::getFps (  )  const

Get the number of frame per second (typically between 5 and 100 fps).

Returns:
The current number of frame per second.
Input & SDLWindow::getInput (  ) 

Get mouse and keyboard current state.

Returns:
Input instance.
void SDLWindow::init ( void *  conf  ) 

Initialize all the SDL stuff, or reintialize windows with a new set of values.

Parameters:
conf Window configuration (size, fullscreen, ...).

References isInitialized().

Referenced by sdlvisu::VisuApp::init().

bool SDLWindow::isFullScreen (  )  const

Check if the window is in fullscreen mode.

Returns:
true if the window is in fullscreen mode.
bool SDLWindow::processOneFrame ( bool  events_only = false  ) 

Update SDL events, update screen (and all his children), and print one frame on the screen.

Parameters:
events_only Turn true to update SDL events only.
Returns:
true if the window is/was/want to be closed.

References isInitialized(), VirtualSurface::render(), Input::reset(), VirtualSurface::update(), and Input::update().

void SDLWindow::setFullScreen ( bool  enable  ) 

Set the fullscreen mode.

Parameters:
enable Enable/disable fullscreen mode.

References isInitialized().


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:17:44 2010 for Stechec/TBT by  doxygen 1.6.3