Fix memory and style issues
This commit is contained in:
@@ -77,18 +77,12 @@ rse_err_t mesh_create_from_file(struct graphics_context_t* context, const char*
|
|||||||
|
|
||||||
STATUS_CHECK(file_load_gltf(file_name, &data));
|
STATUS_CHECK(file_load_gltf(file_name, &data));
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Attribute name: %s", data->meshes->primitives[0].attributes[3].name);
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Accessor: %ld", data->meshes->primitives[0].attributes[3].data->count);
|
|
||||||
|
|
||||||
for (mesh_index = 0U; mesh_index < data->meshes_count; ++mesh_index) {
|
for (mesh_index = 0U; mesh_index < data->meshes_count; ++mesh_index) {
|
||||||
mesh = &data->meshes[mesh_index];
|
mesh = &data->meshes[mesh_index];
|
||||||
|
|
||||||
for (primitive_index = 0U; primitive_index < mesh->primitives_count; ++primitive_index) {
|
for (primitive_index = 0U; primitive_index < mesh->primitives_count; ++primitive_index) {
|
||||||
primitive = &mesh->primitives[primitive_index];
|
primitive = &mesh->primitives[primitive_index];
|
||||||
|
|
||||||
for (attribute_index = 0; attribute_index < primitive->attributes_count; ++attribute_index) {
|
|
||||||
attribute = &primitive->attributes[attribute_index];
|
|
||||||
|
|
||||||
if (primitive->indices == NULL) {
|
if (primitive->indices == NULL) {
|
||||||
SDL_LogCritical(SDL_LOG_CATEGORY_GPU,
|
SDL_LogCritical(SDL_LOG_CATEGORY_GPU,
|
||||||
"No indices for mesh found. Currently only indexed drawing is supported");
|
"No indices for mesh found. Currently only indexed drawing is supported");
|
||||||
@@ -100,6 +94,9 @@ rse_err_t mesh_create_from_file(struct graphics_context_t* context, const char*
|
|||||||
rse_malloc(indices, (sizeof(uint16_t) * indices_count));
|
rse_malloc(indices, (sizeof(uint16_t) * indices_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (attribute_index = 0; attribute_index < primitive->attributes_count; ++attribute_index) {
|
||||||
|
attribute = &primitive->attributes[attribute_index];
|
||||||
|
|
||||||
tmp_offset = attribute->data->buffer_view->offset;
|
tmp_offset = attribute->data->buffer_view->offset;
|
||||||
|
|
||||||
switch (attribute->type) {
|
switch (attribute->type) {
|
||||||
@@ -169,7 +166,9 @@ exit:
|
|||||||
rse_free(position_data_offset);
|
rse_free(position_data_offset);
|
||||||
rse_free(color_data_offset);
|
rse_free(color_data_offset);
|
||||||
rse_free(texture_coord_data_offset);
|
rse_free(texture_coord_data_offset);
|
||||||
|
rse_free(indices_data_offset);
|
||||||
rse_free(vertices);
|
rse_free(vertices);
|
||||||
|
rse_free(indices);
|
||||||
cgltf_free(data);
|
cgltf_free(data);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "red_scarf_engine.h"
|
#include "red_scarf_engine.h"
|
||||||
#include "utilities/commons.h"
|
|
||||||
#include "utilities/errors_common.h"
|
#include "utilities/errors_common.h"
|
||||||
#include "graphics/src/mesh_controller.h"
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user