Hello.
I’ve been mucking about with Urho3D for a few days now. Yesterday I tried to start and run the engine without any of the file-based resources that come with Urho3D. That involves setting up the render path manually, also creating geometries and shaders on the fly. It works, but the API doesn’t make it easy for people to use the engine from scratch.
Here’s a few suggestions that would help a lot with gaining control of the API without adding much overhead for the API user:
-
Ditch the current prefix / data paths setup.
Is the extra code of having to write cache->AddResourceDir(mypath) really worth reducing flexibility over? I suggest a build time const char * or define that holds the Urho3D data home. It CAN be used, but
nobody is forced to use it. Thusly, the exact same thing done by the engine parameters could be done in Setup with cache->AddResourceDir(URHO3D_DEFAULT_PATH + “/Data”)
and cache->AddResourceDir(URHO3D_DEFAULT_PATH + “/CoreData”). Two lines of code to replace the enigne parameters and the sort of messy code in Engine::Initialize. You could also ditch the whole “prefix” and “actual
path” separation, this is bread and butter code, we don’t need the engine to handle this. (also Urho3D provides nice portable filesystem features, so all in all this is better to leave to the user)
Trying to figure out every use case is impossible, so I’m better of finding and adding my own resource directories as I please and also handle possible errors. At worse, the poor user must write two lines of code to replace
everything that’s automagic through engine parameters and Initialize right now.
This would also help with the ridiculous install policy to put data in $PREFIX/bin (it should be in $PREFIX/share), the sample binaries should use the URHO3D_DEFAULT_PATH as set during Urho3D build to know where the data is. -
Default render path, textures, style and UI should NOT be loaded automatically.
Again, what if I don’t want to use them? Try to break this out into a separate call after the engine has been initialized, it will also allow the user to
catch missing file errors and react accordingly, perhaps add more resource dirs or whatever. No reason to limit the API usability for this tiny extra bit of automagic.
Perhaps just add a convencience call like Engine::InitializeDefaultResources, but really, I think users should explicitly have to load the resources. It’s 6 lines of code you’re saving us from. -
RenderPath needs helper methods to create or set specific RenderPathCommand’s. Right now it’s a pain to set up a 7 command render pass manually. It wouldn’t hurt if there was a way to “zero” it or maybe a const somewhere
with an empty, like RenderPathCommand::EMPTY.
Thank you for taking time to read through all of that. I hope it isn’t all nonsense, my focus is bad when I write so much text that isn’t code.