Skip to content

feat: LoadTMXFromMemory#31

Open
cortexmancer wants to merge 1 commit intoRobLoach:masterfrom
GameDev-Masters:feat/LoadTMXFromMemory
Open

feat: LoadTMXFromMemory#31
cortexmancer wants to merge 1 commit intoRobLoach:masterfrom
GameDev-Masters:feat/LoadTMXFromMemory

Conversation

@cortexmancer
Copy link
Copy Markdown
Contributor

@cortexmancer cortexmancer commented Feb 2, 2026

Hello. I took the liberty to implement this TODO and notice some things.

Looking at baylej/tmx#58 is kinda hard to understand because it seens like baylej forced pushed on your commit, instead of creating a new one.

But I think you intended to tmx_load_buffer_path to acts like tmx_rcmgr_load_buffer_vpath is acting but without the definition of an resource manager. Due to this, it is impossible for the current function tmx_load_buffer_path to find files in a path of a given fileName.

The tests shows that to use this method correctly as it is, without defining the resource manager, the user must control the current directory that is loading. I don't think that is a great deal anyway.

Let me know what you think?

Was that your idea?
Is this implementation okay?
Do you think we should handle the resource_manager somehow?

  • Implementation
  • Test
  • Example?
  • Update README

closes #4 ?

@RobLoach
Copy link
Copy Markdown
Owner

RobLoach commented Feb 2, 2026

This is great, thanks for taking it on. Glad baylej brought in the change. While I haven't looked deep into how it's set up, I think we'd need to figure out the virtual path stuffs within tmx.

Loading a map from a buffer is helpful if you're loading the map from a .zip file, or another virtual file system. Like through https://github.com/RobLoach/raylib-physfs .

#define RAYLIB_PHYSFS_IMPLEMENTATION
#include "raylib-physfs.h"

int main() {
    // Initiatize the file system.
    InitPhysFS();
    MountPhysFS("resources.zip", "res");

    // Load an image through PhysFS directly from resources.zip.
    tmx_map* map = LoadTMXFromPhysFS("res/map.tmx");

    // TODO: Since the "res" basepath isn't sent through to
    // LoadTMXFromPhysFS(), how does the .tmx know where to load its images?

    // Close the file system.
    ClosePhysFS();
}

But again, the buffer loading is only helpful if you're using something other than raylib's stdio file loading.

@cortexmancer
Copy link
Copy Markdown
Contributor Author

Loading a map from a buffer is helpful if you're loading the map from a .zip file, or another virtual file system. Like through https://github.com/RobLoach/raylib-physfs .

I was asking myself why this was helpful! Nice input.

So some points:

  1. It would be useful to pack everything in a zip file, for better maintaining in a real scenario where resources/assets are too much for just git it?
  2. Would physfs be the concrete implementation of the resource manager? I need to take a look at how this manager works. So far I've implemented things as they appeared by my needs and I didn't have a need or reference point to check up the resource manager feature.
  3. This PR surely then will be far more complex, and this current implementation then don´t really have a useful meaning to a user as it is then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use raylib file loading methods

2 participants