Manage SDL Window.Manage creation of a SDL Window and collect its events into Input class. More...
#include <SDLWindow.hh>
Public Member Functions | |
| Input & | getInput () |
| Get mouse and keyboard current state. | |
| VirtualSurface & | getScreen () |
| 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. | |
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; } }
| int SDLWindow::getFps | ( | ) | const |
Get the number of frame per second (typically between 5 and 100 fps).
| void SDLWindow::init | ( | void * | conf | ) |
Initialize all the SDL stuff, or reintialize windows with a new set of values.
| conf | Window configuration (size, fullscreen, ...). |
References isInitialized().
Referenced by sdlvisu::VisuApp::init().
| bool SDLWindow::isFullScreen | ( | ) | const |
Check 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.
| events_only | Turn true to update SDL events only. |
References isInitialized(), VirtualSurface::render(), Input::reset(), VirtualSurface::update(), and Input::update().
| void SDLWindow::setFullScreen | ( | bool | enable | ) |
Set the fullscreen mode.
| enable | Enable/disable fullscreen mode. |
References isInitialized().
1.6.3