Browse Source

clean up rgAppend()

render_group_fix
cinnaboot 5 years ago
parent
commit
f4c50602b4
  1. 24
      src/renderer.cpp

24
src/renderer.cpp

@ -61,23 +61,27 @@ rgAppend(render_group* rg,
memory_arena* arena,
const char* model_path)
{
assert(rg != nullptr);
if (rg->count < rg->max_size) {
entity* e = &rg->entities[rg->count];
rg->count++;
// FIXME: maybe actually load the model here...
// get path hash
// check for hash in rs->assets->models[i]->filepath_hash
// load new model if not found
model* mdl = assetGetCached(assets, utilFNV64a_str(model_path));
if (mdl == nullptr)
// NOTE: not cached
if (mdl == nullptr) {
mdl = assetLoadFromFile(assets, arena, model_path);
// load model into gl, entInitModel(e, model)
if (entInitModel(e, mdl))
if (mdl == nullptr) {
LOG(Error) << "Error loading model: " << model_path << "\n";
return nullptr;
}
}
if (entInitModel(e, mdl)) {
rg->count++;
return e;
} else {
LOG(Error) << "Error initializing GL buffers\n";
return nullptr;
}
}
LOG(Error) << "no free entity in render_group\n";

Loading…
Cancel
Save