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
and PixelGrid
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
bool SlimApp::OnReady()
-
The Defaults
stuct members were moved into the app instance.
They can be overridden either in createApp()
or OnReady()
.
-
Platform moved to being a (static)struct with static-only members os
instead of a member instance of App
(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.