DubiousEngine
0.2.0
Simple Game Engine
|
Top Level SDL Manager. More...
#include <Sdl_manager.h>
Public Types | |
typedef std::pair< int, int > | Mouse_point |
Public Member Functions | |
Sdl_manager () | |
Constructor. More... | |
Sdl_manager (const Sdl_manager &)=delete | |
~Sdl_manager () | |
Destructor. More... | |
Sdl_manager & | operator= (const Sdl_manager &)=delete |
void | create_root_window (const std::string &title, int width, int height, bool full_screen) |
Creates a root window of the specified dimensions. More... | |
void | run () |
Main function for running a program. More... | |
void | stop () |
Stops the application. More... | |
std::function< void()> & | on_quit () |
accessor to the onQuit event. More... | |
std::function< void()> & | on_idle () |
Called by the system during idle time. More... | |
std::function< void(const Mouse_point &)> & | on_mouse_motion () |
called when the mouse is moved. More... | |
std::function< void(const Mouse_point &)> & | on_mouse_left_down () |
called when the left mouse button is pressed More... | |
std::function< void(const Mouse_point &)> & | on_mouse_left_up () |
called when the left mouse button is released More... | |
std::function< void(const Mouse_point &)> & | on_mouse_right_down () |
called when the right mouse button is pressed More... | |
std::function< void(const Mouse_point &)> & | on_mouse_right_up () |
called when the right mouse button is released More... | |
std::function< void(int)> & | on_mouse_wheel () |
called when the scroll wheel is moved More... | |
std::function< void(SDL_Keycode, unsigned short)> & | on_key_down () |
called when a key is pressed. More... | |
Top Level SDL Manager.
Collection of top level functions for any application. Use this class to create your main window, setup your OpenGL, and respond to system events. Any application using this engine will need to make use of this object. Events are implemented as function pointers. Set each one to a function and it will be called when the event triggers. The OnIdle event is of particular importance as it is a good time to run your physics and redraw your OpenGL scene.
typedef std::pair<int, int> Dubious::Utility::Sdl_manager::Mouse_point |
Dubious::Utility::Sdl_manager::Sdl_manager | ( | ) |
Constructor.
|
delete |
Dubious::Utility::Sdl_manager::~Sdl_manager | ( | ) |
Destructor.
void Dubious::Utility::Sdl_manager::create_root_window | ( | const std::string & | title, |
int | width, | ||
int | height, | ||
bool | full_screen | ||
) |
Creates a root window of the specified dimensions.
Probably the first thing you will call.
title | - [in] the window title |
width | - [in] window width, in pixels |
height | - [in] window height, in pixels |
full_screen | - [in] whether or not you want a full screen of a window |
|
inline |
Called by the system during idle time.
This is called when all of the mouse events have been handled and there is nothing else to do. It will only be called a certain amount of times per second. Draw your scene and run your physics
|
inline |
called when a key is pressed.
See the SDL docs for specifics on the meanings of the arguments
|
inline |
called when the left mouse button is pressed
|
inline |
called when the left mouse button is released
|
inline |
called when the mouse is moved.
|
inline |
called when the right mouse button is pressed
|
inline |
called when the right mouse button is released
|
inline |
called when the scroll wheel is moved
|
inline |
accessor to the onQuit event.
Set this to whatever event you want to fire when the system is quitting
|
delete |
void Dubious::Utility::Sdl_manager::run | ( | ) |
Main function for running a program.
Call this function to begin the main application loop and fire events. The program will not return from this function until Stop is called (or the user closes the main window.
void Dubious::Utility::Sdl_manager::stop | ( | ) |
Stops the application.
Causes the OnQuit function to be called and the Run function to return. Often a good idea to call this when a Quit key or Quit menu option is pressed.