-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rREM] Update raylib Resource EMbedder! #193
Comments
Just started work on the new rRES (raylib resource) custom file format. Here a pre-liminary version of the API: rres.h |
RRES file format support will be ready for raylib v1.7 but visual tool could take a bit longer. Probably rREM will be command line only on first implementation... |
Hi Ray, I now you are busy with new release, just wanted to ask what is the status of rREM util? In Go bindings I started with something like this https://github.com/gen2brain/raylib-go/blob/master/raylib/rres.go , but I can't test, source for rREM util is missing, and I am not sure what final format would be. I would like to make a binary util for that, in native Go it can be easily cross compiled. |
Hi Milan! Lately I've been pretty busy in my daily job, preparing classes, setting and correcting exercises, preparing exams... I didn't have much time to focus on rres.h (implementation isn't complete), neither in rREM; latest implementation of that tool dates from 2014 (completely outdated, needs to be reworked from scratch) and the format has been improved a lot... despite it still requires some decisions:
In any case, I attach old rREM implementation for reference (rREM.zip) but this tool is deprecated right now... Ok, my plan, I'll publish raylib v1.7 as soon as possible (no more than two weeks, despite not being complete with all the features I wanted...) and I'll put on high priority this tool. |
I implemented resource embedder in Go based on what is currently in rres.h https://github.com/gen2brain/raylib-go/tree/master/rres/cmd/rrem . It is in native Go so it is easy to compile or cross compile (just go build, no need for C compiler etc.) , binary format should be compatible. There are also options to generate .h and .c files, and it can generate .go file so everything can be compiled in binary, encrypted and compressed. Currently I have an issue with deflate (only for images, wav's are ok, they are incomplete, not sure if that is only read or both read/write issue, it happens with both official and the library I use) so default is LZMA2 (XZ).
Here is the Windows binary in case you want to check, http://81.4.106.254/rrem.exe . Maybe there are no issues with C deflate. |
Hi @gen2brain! Great work! Sorry for forgetting about this issue... I've been busy with lots of things.
I think it's not clear enough for anyone... The objective was using it to define differents chuncks of data (parts) for a related piece of data... for example, SpriteFonts, two parts, one part is the sprite image atlas and second part is the charset info data. Another example, Models, they are composed of multiple vertex data chuncks of different type. But managing those chunks of data on loading is a bit complicated... I tried to download the Windows binary but my system blocks the file, could you rename it to something like |
Hi, file is renamed, http://81.4.106.254/rrem.renamed . Also, I opened issue about DEFLATE here klauspost/compress#82 . Not sure what I am doing wrong there, because it works with other compressed formats. Btw. it is posible to create a library in Go that only has Compress/Decompress and Encrypt/Decrypt functions, with all algorithm supported, i.e. DEFLATE, LZ4, LZMA2, BZIP2, AES, 3DES, Blowfish, XTEA etc. and then compile to C static library with It maybe sounds strange, but then you would not need all the dependencies for C version. |
Hey @gen2brain! Just tested it! It works great! :D About DEFLATE, why not using miniz, it worked great for me...
Wow! That would be amazing! Which libraries are you using for all those algorythms? I understand that generated .a library has no external dependencies at all, right?
Afte some years in coding, what would sound strange to me would be something not being possible to do... :P |
DEFLATE issue was my fault, it is fixed now. Most of the libraries are from official Go standard lib, like https://golang.org/pkg/crypto/#pkg-subdirectories and https://golang.org/pkg/compress/ , maintained and well tested code. Some are from https://github.com/dsnet/compress and https://github.com/klauspost/compress , some of that work is probably going to be also included in standard lib. Yes, generated .a will have no external dependencies, I did something similar recently with other project. I will try something these days. Something like this is ok I guess: |
That's great!
Absolutely! By the way, how you determine the compression algorythm with those functions? Maybe using: unsigned char *Compress(int compType, const unsigned char *data, unsigned long uncompSize, unsigned long *outCompSize) Just an idea... |
Sure, compType and encType for Encrypt/Decrypt will need to be passed. I forgot that. |
Ok, I created Cgo library here https://github.com/gen2brain/raylib-go/tree/master/rres/rlib/cgo . Some binary releases are here http://81.4.106.254/rlib-release.zip . I don't like it, header files are platform dependent and they generate something like this, without parameter names that are defined: I guess just DEFLATE and XOR will be fine enough. Main feature I see here is to compile resources together with binary, not to compress and encrypt with some ultra encryption so nobody can extract your file. |
Hi @gen2brain, excuse me I'm a bit confused, probably due to naming... So, Maybe naming it |
Yes, naming is bad, should be renamed to rreslib. Yes, Cgo is a tool for bridging C and Go, either to use library from C in Go, or to export/generate library that can be used in C. How it is currently, here is the lib in Go https://github.com/gen2brain/raylib-go/blob/master/rres/rlib/rlib.go , and this is a wrapper to cgo lib https://github.com/gen2brain/raylib-go/blob/master/rres/rlib/cgo/rlib.go. |
Renamed here gen2brain/raylib-go@275bcd3 . |
Just moved project to own repo: https://github.com/raysan5/rres Also worked a bit further on format design, I'll upload a new specs design this weekend... basically, I support multiple data chunks per resource (similar to RIFF file-format). After thinking quite long on that, I think it's the best option, it also adds a lot of versatility for users to customize own resources data. |
Here it is the proposed update for rRES: I reviewed the specs based on feedback provided on Handmade Network post and a more deep review of RIFF and ZIP file-formats. My only concern is, maybe, using on each data chunk 4 byte for chunkType, compType, crypType, paramCount and use 4 bytes for a CRC32, I mean, this: chunkInfoHeader: What do you think? EDIT: After looking at it more carefully, I think the version with CRC32 is better. |
By the way, probably this discussion should be moved to new rres repo: https://github.com/raysan5/rres |
Just removed .rres file support from raylib in commit a6f9cc5. This way we let the user to choose if using custom resource files, just including the Additional work has started on new rrem tool based on new rres format specs, along rrem design I will see format requirements and possible changes and improvements. |
By the way, @gen2brain, did you see this issue? what are your thoughts? |
Looks great, I would prefer to go without that crc32 if possible, only complicates things it seems. So rres.h is not required anywhere anymore, right? That is great, I would also like to remove that from raylib/ directory and put it in separate module so that can be used when needed. It adds a lot of additional dependencies when used. Will need some time to update code, raylib-go will have just cmd util, you are working on real tool there :) |
Any plans maybe for function/s that should load Music files from resource? I think I will have some problems there in Go. |
Hi @gen2brain! Thanks for your quick answer!
I added that field after lot of reading on fileformats, ZIP and PNG use it for data corruption detection, PNG specs also provide C code about implementation. CRC is also recommended here and here or even here. The truth is that there is not much information out there on designing custom file-formats, it seems very case-specific and information usually points to 3 well-designed formats: RIFF, PNG and ZIP.
That's right. Using it is a user decision.
Just trying to create a simple raygui-based tool for rres generation (also usable from command line), similar to MonoGame Content Pipeline tool.
Still thinking on that issue... even XNB file-format uses external WMA access, referenced from XNB file. Embedding OGG music files into a .rres won't be a good idea... |
Thanks, that was a good read. I am no expert here, I just passed what I thought I see at that moment, but now I can understand how and where CRC can help. I actually work as sysadmin, programming is just a hobby, but I must say that since I started playing with raylib I feel like I upgraded to new level and got some new skills :) And I only learned some C through Python ctypes and Go cgo, nothing serious. Music files can stay where they are and don't need to be bundled if that is simpler, and it looks like it is a much simpler to do that. Usually user will not have many of those and it is not big deal if they are not bundled in resources. Btw. I recently played with ZIP format, I wanted to corrupt archives on purpose, but in different ways, so I can use them in tests, I found out that https://github.com/evanmiller/hecate is a great tool for that, much better that any other hex editor I found. We can continue discussion on new rres github project in the future. |
Moving this issue to rres project. Check raysan5/rres#1, raysan5/rres#2, raysan5/rres#3. |
Update raylib Resource Embedder (rREM)...
The text was updated successfully, but these errors were encountered: