VxfFile * vxf_open_stream(FILE *stream, VxfError *error)
Opens a MagicaVoxel vox file from a stdio file stream.
size_t vxf_read_xyz_coloridx(VxfFile *vf, size_t max_count, int32_t xyz_buf[][3], uint8_t coloridx_buf[], VxfError *error)
Reads voxel positions and color indices.
struct VxfFile VxfFile
Opaque struct representing an opened MagicaVoxel vox file.
Definition voxflat.h:16
uintmax_t vxf_count_voxels(const VxfFile *vf)
Counts the total number of voxels in the file.
VxfError
Error codes for open and read functions.
Definition voxflat.h:21
@ VXF_ERROR_FILE_SEEK
Definition voxflat.h:25
@ VXF_ERROR_FILE_OPEN
Definition voxflat.h:23
@ VXF_ERROR_FILE_READ
Definition voxflat.h:24
@ VXF_ERROR_OUT_OF_MEMORY
Definition voxflat.h:30
@ VXF_SUCCESS
Definition voxflat.h:22
@ VXF_ERROR_UNEXPECTED_EOF
Definition voxflat.h:27
@ VXF_ERROR_INVALID_FILE_STRUCTURE
Definition voxflat.h:28
@ VXF_ERROR_INVALID_SCENE
Definition voxflat.h:29
@ VXF_ERROR_INVALID_ARGUMENT
Definition voxflat.h:31
@ VXF_ERROR_UNRECOGNIZED_FILE_FORMAT
Definition voxflat.h:26
VxfFile * vxf_open_file(const char *filename, VxfError *error)
Opens a MagicaVoxel vox file from a filename.
void vxf_get_palette(const VxfFile *vf, uint8_t rgba_buf[256][4])
Retrieves the color palette.
void vxf_close(VxfFile *vf)
Destroys a VxfFile instance.
VxfFile * vxf_open_memory(size_t size, const char buffer[], VxfError *error)
Opens a MagicaVoxel vox file from a memory buffer.
void vxf_calculate_bounds(const VxfFile *vf, int32_t xyz_min[3], int32_t xyz_max[3])
Calculates the bounding box of the voxel data.
size_t vxf_read_xyz_rgba(VxfFile *vf, size_t max_count, int32_t xyz_buf[][3], uint8_t rgba_buf[][4], VxfError *error)
Reads voxel positions and RGBA colors.
const char * vxf_error_string(VxfError error)
Converts an error code to a human-readable string.