Hey. I've set up a really basic project and I'm looking at the code thinking how to organise this stuff for a bigger project. Even IRefCounted from memory serves one purpose and is very small(?)
So I have never used a function pointer, but why not create a custom helper function that takes a irr::create function parameter (that needs drop) and call drop from within the custom helper function?
#include <iostream> // messages are in main
#include "irrlicht.h"
using namespace irr;
struct A // a. for irrlicht stuff
{
IrrlichtDevice * device;
video::IVideoDriver * driver;
scene::ISceneManager * smgr;
} a; // only one please
struct B // b. for game stuff
{
enum class ESTATE { INIT=0, MENU, GAME, PAUSE };
ESTATE es;
} b; // again only one
int main()
{
b.es = b.ESTATE::INIT; // also B::ESTATE so can be confusing
a.device = createDevice (...) // now I must remember to us 'a.'!
a.driver = getVideoDriver();
a.smgr = getSceneManager();
// Put camera in
// Put cube in
while(a.device->run() && ...active())
{
a.driver->beginScene(...);
a.smgr->drawAll();
a.driver->endScene();
// still must remember to use 'a.'!
}
a.device->drop();
return 0;
}
So I've had to separate into structs (me and Noie wanted the procedural / C style C++ which is completely okay to do). The data is still held somewhere, be that in an instance or struct, so I don't see problems there.
I started adding header files and things to separate enemies and irr maps but so far it's an interesting procedure to act like the Irrlicht source code (only this is a game made in Irr and not and engine by itself).
Maybe only use new headers when needed. Not sure yet.
As long as you don't call drop() before you are done using the pointer you can do whatever you want.
Single character names are bad, I hope that was just as example :-) So if it's game stuff call it GameStuff not b.
In general - one class one Header. Sometimes it's a bit annoying and people are lazy and put more than one class declaration in a header if they belong strongly together.
Cool. The function, aptly named "callAndHandleCreate()" or something that tells the programmer to only to use the "create" Irr functions sounds kinda alrighty. I mean push the boundaries a bit by allowing modifications to the game. This is NOT a game engine, but companies have released the source code and people use company code. Just think of a big game someone can download the source and make their own mods!