SlimApp ported into ideomatic C++ (OOP-style) on a separate branch (cpp): https://github.com/HardCoreCodin/SlimApp/tree/cpp/src
Notable changes:
-
Structs now embody their related functions as member methonds (including
App
andPixelGrid
which now embeds all drawing functions) -
Entry point (only thing that needs to be defined) is now ```cpp SlimApp* createApp()
instead of: ```c void initApp(Defaults *defaults)
it now needs to return a pointer to the app, which could be an instance of a sub-class
-
All callbacks are now overridable virtual methods on the
SlimApp
struct. -
init
is now a virtual method and has a detault implementation (so not required):
bool SlimApp::OnReady()
-
The
Defaults
stuct members were moved into the app instance. They can be overridden either increateApp()
orOnReady()
. -
Platform moved to being a (static)struct with static-only members
os
instead of a member instance ofApp
(app.platform
) so:cpp os::setWindowCapture(true); os::setCursorVisibility(false);
instead of: ```c app->platform.setWindowCapture(true); app->platform.setCursorVisibility(false);
- Rect now passed by refference (instead of by pointer): ```cpp void drawShapesToCanvas(PixelGrid &canvas) { // Draw and fill a rectangle with different colors: Rect rect; rect.min.x = rect.min.y = 100; rect.max.x = rect.max.y = 300; canvas.fillRect(Color(Blue), rect); canvas.drawRect(Color(Red ), rect);
All sample apps tested and working.