DubiousEngine  0.2.0
Simple Game Engine
Dubious::Utility::Sdl_manager Class Reference

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_manageroperator= (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...
 

Detailed Description

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.

Member Typedef Documentation

typedef std::pair<int, int> Dubious::Utility::Sdl_manager::Mouse_point

Constructor & Destructor Documentation

Dubious::Utility::Sdl_manager::Sdl_manager ( )

Constructor.

Dubious::Utility::Sdl_manager::Sdl_manager ( const Sdl_manager )
delete
Dubious::Utility::Sdl_manager::~Sdl_manager ( )

Destructor.

Member Function Documentation

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.

Parameters
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
std::function<void()>& Dubious::Utility::Sdl_manager::on_idle ( )
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

std::function<void(SDL_Keycode, unsigned short)>& Dubious::Utility::Sdl_manager::on_key_down ( )
inline

called when a key is pressed.

See the SDL docs for specifics on the meanings of the arguments

std::function<void(const Mouse_point&)>& Dubious::Utility::Sdl_manager::on_mouse_left_down ( )
inline

called when the left mouse button is pressed

std::function<void(const Mouse_point&)>& Dubious::Utility::Sdl_manager::on_mouse_left_up ( )
inline

called when the left mouse button is released

std::function<void(const Mouse_point&)>& Dubious::Utility::Sdl_manager::on_mouse_motion ( )
inline

called when the mouse is moved.

std::function<void(const Mouse_point&)>& Dubious::Utility::Sdl_manager::on_mouse_right_down ( )
inline

called when the right mouse button is pressed

std::function<void(const Mouse_point&)>& Dubious::Utility::Sdl_manager::on_mouse_right_up ( )
inline

called when the right mouse button is released

std::function<void(int)>& Dubious::Utility::Sdl_manager::on_mouse_wheel ( )
inline

called when the scroll wheel is moved

std::function<void()>& Dubious::Utility::Sdl_manager::on_quit ( )
inline

accessor to the onQuit event.

Set this to whatever event you want to fire when the system is quitting

Sdl_manager& Dubious::Utility::Sdl_manager::operator= ( const Sdl_manager )
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.


The documentation for this class was generated from the following files: