spjewkes / sdl_framework

Simple SDL framework on which other projects can be based

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDL Framework

This is a simple SDL 2 framework to be used when constructing other projects. The intention is that the SDL framework class is inherited and the virtual functions are overridden that provide the functionality you wish to add.

The functions for overriding are:

  • OnCreate() - allows for any initialization prior to running the update loop. Return true to indicate that initialization was successful. Returning will cause the framework to exit.
  • OnUpdate() - when framework is running this is called repeatedly to allow your project to do any necessary updates (including drawing to the screen). An elapsed time value is passed to indicate the time passed since the last OnUpdate() call (this is a floating-point value indicating the number seconds). Returning true from this function ensures that another update will be called. Returning false will cause the framework to exit. It is the responsibility of this function to call whatever is needed to update the SDL window.
  • OnDestroy() - called once as the framework exits. This allows any necessary clean up of resources.

The SDL framework class provides other utility functions for accessing information about the SDL window created and controlled by the framework.

  • get_window() - returns the SDL window reference.
  • get_renderer() - return the SDL renderer context for the SDL window (this is created on start-up).
  • width() - return the width in pixels of the SDL window.
  • height() - return the height in pixels of the SDL window.

NOTE: This is currently designed for building on a Mac OS X and Linux only

About

Simple SDL framework on which other projects can be based


Languages

Language:C++ 94.4%Language:CMake 3.6%Language:Shell 2.0%