Jackalope / jrf (public) (License: GPLv3 or later version) (since 2019-11-21) (hash sha1)
Libriary for reading and writing resource files: vertices, indices, meshes, images, models and scene data.
Supports reading from filesystem as well as from zip files.
It uses unique binary container format for those resources.
It is used in tool for converting popular formats like wavefront .obj file, TARGA image to this container and also used in resource loader as part of graphics framework.

It requires jlib libriary (see my user repositories) and libzip.
It is possible to remove libzip dependency.
List of commits:
Subject Hash Author Date (UTC)
changed vertices file structure to prevent undefined behaviour 603e283ccf234f87f6e8c38a669280be36a5aafb jp.larry 2019-12-26 12:35:05
vertex attributes is separated, not inteleaved now d3e7b79c74e9fae7b8b788d1a55db2e664feb107 jp.larry 2019-12-26 01:19:17
compiled on windows with mingw 51eacaf02dd542415cea1edd615d88234fb5b344 Jackalope 2019-12-15 07:05:58
added mesh to read and write functions 173144a8516441420feb4327a66d26fa3f57376d Your Name 2019-12-07 22:09:04
warning hidden by implicit cast f49b32439aa1e8719bd340da9fc3bb7e9b906d0d Your Name 2019-12-07 21:01:08
Vertices have vertices count value cf3b63932cdcdb88b72e70df93a4dd8b478d163b jp.larry 2019-12-07 16:02:55
removed IndicesArrays, added Mesh resource and Vertices attributes is not dynamically allocated a54a61cfc285bbec4246b1affdc5fe9251c059d0 jp.larry 2019-12-06 17:04:06
new obj file error f4385161fdd1ad8038e2d0924e1d3de2a6506cc9 Your Name 2019-12-01 10:26:18
scene issues solved cef4ba84d44cbdc6690c87e553df9fbfba60059f Your Name 2019-12-01 04:19:29
changed transformation matrix to 4x4 from 3x3 5b5728dabefb471cf126bf4b524f5079a14c0735 Your Name 2019-11-30 15:16:50
added missing return 94644ed6f61207f664ac4675fa015afbe017ddea jp.larry 2019-11-29 09:03:14
scene improvements, changed shift type to unsigned, set default-value funtions, model must be path a2708b94b88eb0ede73b9aab396e7a13f13baa52 Your Name 2019-11-29 09:27:32
separate function for str reading 9127f9a18f9f4974975fa35d58f596952b6aa4e5 Your Name 2019-11-29 09:26:43
new result errors ef56e017e2e761fdf23c6a64ed33277c98569e13 Your Name 2019-11-29 09:26:12
new types for Scene e2fde0d2b66e125ba3bfd86b8f51c81ecb5ab047 Your Name 2019-11-29 00:38:27
shift scale added to Scene 974752944e73bbc2949ff399ab9d806baeeab751 Your Name 2019-11-29 00:38:06
new resource type - scene - list of models f3eea43135dad8b3e24cf6683e5abc1a5e2e57ad Your Name 2019-11-28 07:59:59
model correctly handling error returns 3df9ec0f9abed56709b8b9556a5291217ad8744d Your Name 2019-11-28 07:59:25
updated jlib 2a28ba18170dc757f7bad931a12a34ee3e7e1c46 Your Name 2019-11-27 03:44:11
replaced free with jl::deallocate ab8d6cb89f814227c280797dbe654971a85264a6 Your Name 2019-11-25 07:29:05
Commit 603e283ccf234f87f6e8c38a669280be36a5aafb - changed vertices file structure to prevent undefined behaviour
Author: jp.larry
Author date (UTC): 2019-12-26 12:35
Committer name: jp.larry
Committer date (UTC): 2019-12-26 12:35
Parent(s): d3e7b79c74e9fae7b8b788d1a55db2e664feb107
Signing key:
Tree: 3bcbc51d9dc8591e23a5983da2c4079e65817834
File Lines added Lines deleted
include/jrf/image.h 1 1
include/jrf/result.h 1 1
include/jrf/vertices.h 17 18
src/result.cpp 1 1
File include/jrf/image.h changed (mode: 100644) (index 7dd3ca5..a52b381)
... ... namespace jrf
62 62 if (size == 0) if (size == 0)
63 63 { {
64 64 p_pixels = nullptr; p_pixels = nullptr;
65 return Result::NO_DATA_FROM_SOURCE;
65 return Result::FILE_NO_DATA;
66 66 } }
67 67
68 68 if (not jl::allocate_bytes(&p_pixels, size)) if (not jl::allocate_bytes(&p_pixels, size))
File include/jrf/result.h changed (mode: 100644) (index 2760e92..07271ac)
... ... namespace jrf
57 57
58 58 //file //file
59 59 FILE_OPEN_ERROR, FILE_OPEN_ERROR,
60 FILE_NO_DATA,
60 61 DIRECTORY_ERROR, DIRECTORY_ERROR,
61 NO_DATA_FROM_SOURCE,
62 62
63 63 //zip //zip
64 64 ZIP_IN_ZIP_UNSUPPORTED, ZIP_IN_ZIP_UNSUPPORTED,
File include/jrf/vertices.h changed (mode: 100644) (index 21794c0..6338768)
... ... namespace jrf
23 23 }; };
24 24
25 25 enum AttributeType { enum AttributeType {
26 POSITION, TEXTURE_COORDINATE, NORMAL,
26 POSITION, TEX_COORD, NORMAL,
27 27 RESERVED_BEGIN, RESERVED_BEGIN,
28 28 RESERVED_COUNT = 16 RESERVED_COUNT = 16
29 29 }; };
 
... ... namespace jrf
39 39
40 40 Attributes attributes; Attributes attributes;
41 41 uint64_t vecs_count; uint64_t vecs_count;
42 uint64_t vecs_size;
43 void *p_vecs;
42 uint64_t data_size;
43 void *p_data;
44 44
45 void destroy() { jl::deallocate(&p_vecs); }
45 void destroy() { jl::deallocate(&p_data); }
46 46
47 47 template<typename IO = jl::io_agent> template<typename IO = jl::io_agent>
48 48 [[nodiscard]] Result read(IO *p_mediator) [[nodiscard]] Result read(IO *p_mediator)
 
... ... namespace jrf
52 52 if (not p_io->read_items(&attributes)) if (not p_io->read_items(&attributes))
53 53 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
54 54
55 if (not p_io->read_items(&vecs_size))
56 return Result::MEDIATOR_ERROR;
57
58 55 if (not p_io->read_items(&vecs_count)) if (not p_io->read_items(&vecs_count))
59 56 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
60 57
61 if (vecs_size == 0)
62 p_vecs = nullptr;
63 else
64 {
65 if (not jl::allocate_bytes(&p_vecs, vecs_size))
66 return Result::MEDIATOR_ERROR;
67 if (not p_io->read_bytes(p_vecs, vecs_size))
68 return this->destroy(), Result::MEDIATOR_ERROR;
69 }
58 data_size = 0;
59 for (auto a : attributes)
60 data_size += a.dimension_count * FORMAT_SIZE[a.format] * vecs_count;
61
62 if (data_size == 0)
63 return Result::FILE_NO_DATA;
64
65 if (not jl::allocate_bytes(&p_data, data_size))
66 return Result::MEDIATOR_ERROR;
67 if (not p_io->read_bytes(p_data, data_size))
68 return this->destroy(), Result::MEDIATOR_ERROR;
70 69
71 70 return Result::SUCCESS; return Result::SUCCESS;
72 71 } }
 
... ... namespace jrf
77 76 auto *p_io = jl::io_agent_p_alt_cast(p_mediator); auto *p_io = jl::io_agent_p_alt_cast(p_mediator);
78 77 if (not p_io->write_items(&attributes)) if (not p_io->write_items(&attributes))
79 78 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
80 if (not p_io->write_items(&vecs_size))
79 if (not p_io->write_items(&data_size))
81 80 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
82 81 if (not p_io->write_items(&vecs_count)) if (not p_io->write_items(&vecs_count))
83 82 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
84 if (not p_io->write_bytes(p_vecs, vecs_size))
83 if (not p_io->write_bytes(p_data, data_size))
85 84 return Result::MEDIATOR_ERROR; return Result::MEDIATOR_ERROR;
86 85
87 86 return Result::SUCCESS; return Result::SUCCESS;
File src/result.cpp changed (mode: 100644) (index 1ac09c8..497dce7)
... ... const char* jrf::to_str(jrf::Result result)
33 33
34 34 //file //file
35 35 STR(FILE_OPEN_ERROR) STR(FILE_OPEN_ERROR)
36 STR(FILE_NO_DATA)
36 37 STR(DIRECTORY_ERROR) STR(DIRECTORY_ERROR)
37 STR(NO_DATA_FROM_SOURCE)
38 38
39 39 //zip //zip
40 40 STR(ZIP_IN_ZIP_UNSUPPORTED) STR(ZIP_IN_ZIP_UNSUPPORTED)
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Jackalope/jrf

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jrf

Clone this repository using git:
git clone git://git.rocketgit.com/user/Jackalope/jrf

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main