Closed akiriwas closed 3 months ago
A singleton would make sense for those systems that can only be initialized once, for sure. If you're willing to put together a singleton wrapper around them, I'd be happy to go thorugh some testing on it.
I would actually suggest to move the Keyboard and Mouse functions into a namespace instead of the class, as they only have static member functions and it only functions as a name seperator
Speaking of global namespaces, curious how we could avoid two problems...
inline
ed, so it's not an issue.Functions.hpp
, we constantly see this warning. Does this cause problems?
In file included from /home/runner/work/raylib-cpp/raylib-cpp/include/raylib-cpp.hpp:42,
from /home/runner/work/raylib-cpp/raylib-cpp/examples/audio/audio_sound_loading.cpp:12:
/home/runner/work/raylib-cpp/raylib-cpp/include/./Functions.hpp: At global scope:
/home/runner/work/raylib-cpp/raylib-cpp/include/./Functions.hpp:335:35: warning: ‘std::vector<std::__cxx11::basic_string~~~~
/home/runner/work/raylib-cpp/raylib-cpp/include/./Functions.hpp:322:22: warning: ‘std::string raylib::TextInsert(const string&, const string&, int)’ defined but not used [-Wunused-function]
322 | RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) {
| ^~~~~~
/home/runner/work/raylib-cpp/raylib-cpp/include/./Functions.hpp:308:22: warning: ‘std::string raylib::TextReplace(const string&, const string&, const string&)’ defined but not used [-Wunused-function]
308 | RLCPPAPI std::string TextReplace(const std::string& text, const std::string& replace, const std::string& by) {
| ^~~
/home/runner/work/raylib-cpp/raylib-cpp/include/./Functions.hpp:170:35: warning: ‘std::vector<std::__cxx11::basic_string
Shouldn't cause issues, as it is a simple wrapper API. Its rather annoying if you have other warnings/error that are getting drowned by this warning spam. you can just simple disable it with a [[maybe_unused]]
attribute. I will make a PR for fixing the compiler warnings.
Thanks. I'd much prefer static
/global
functions over singleton :+1:
Took the namespace approach here. Thanks!
I've been implementing my project using raylib-cpp because I am a big fan of raylib and using C++ for this project. As I've explored raylib-cpp, I'm starting to wonder if a Singleton pattern was considered for development? Several classes, such as Window, Keyboard or AudioStream are only ever intended to be instantiated once, given that they then pass on calls. Other ones wouldn't make sense, such as Gamepad since it can support multiple Gamepads (and thus multiple object instantiations).
Am I missing something?