Open TokyoSU opened 2 years ago
A few options here...
raylib::Model* model;
instead... construct and delete at ObjectName destructionconst char* path
in as part of the ObjectName constructorI'm not sure how I feel about constructing the object without loading the associated data. Could run into Unload errors... Worth considering though!
Mind submitting a Pull Request? Others may be interested in it too. I'd love to see what you're proposing.
Okay, just need to test more about it, for now, ive not crashed when using this method :) The think is Texture use a default constructor that init a default texture, but i want to load it, i will technicaly have 2 texture for 1 define from a class xD
For this one, it will need some time since i need to check each class and found a way to move some default constructor to function, also testing it to see if it work :)
Quick thought... Would an initializer list for this help here? https://docs.microsoft.com/en-us/cpp/cpp/constructors-cpp?view=msvc-170#member_init_list
class ObjectName
{
public:
ObjectName(const std:string& modelFile);
~ObjectName();
void Load(const char* path);
void Draw(raylib::Vector3 pos);
private:
raylib::Model model;
};
ObjectName(const std::string& modelFile) : model(modelFile) {
// Do other things.
}
A child property will need to know how to construct itself if you're creating the parent.
add a default one ObjectName() so it could be used within other class, else it would just throw a error about not being initialised properly with ObjectName(string), also load the model in the Load() function and use it in ObjectName(string) to avoid problem with it, since you can set the error check only in Load(), also the modder/coder with be able to use Load() manually in custom class. example:
ObjectName(const std:string& modelFile)
{
Load(modelFile);
}
Load(path)
{
if (File.Exist(path))
model.Load(path);
else
Log("File not exist");
}
or something like that. (maybe the model class already check if file path exist so it would be weird to check 2 time for it)
Pretty all class of raylib-cpp have no constructor allowing that:
So it's impossible to create class like this because a error is thrown saying Model have no default constructor !