Resources hotloading

60 views
Skip to first unread message

iarwain

unread,
Oct 31, 2013, 12:55:15 AM10/31/13
to orx...@googlegroups.com
Hey all,

This is mostly a debug feature and has to be manually enabled via config.

The way it works is that orx can now monitor for on-disc resources modifications. When modifications are detected, it'll reload those resources and update some of the content in realtime.
It's currently hooked for textures, config files and sounds (samples, not streams as those can't be modified while orx is using them anyway).

For example, if you modify a texture on disc, orx will then immediately reload it and modify update it in-game, showing the result on screen right away.
This system has some limitations (like changing the size of a texture will not change the size of the body attached to an object, for example), but it still pretty handy.

In addition to those basic resource types, if you ask for config file monitoring, some orx structures will be updated on the fly if they were defined in a config file that just got reloaded. Those structures are:
- shaders (very useful)
- spawners
- fonts
- texts
- sounds

In order to use that feature, simply use the config property WatchList in the Resource section:

[Resource]
WatchList = Texture # Config

Will result in the resource groups "Texture" and "Config" to be monitored, whereas the resource type "Sound" won't.

NB: The resource groups are case sensitive! ie. Texture and not texture.

You can, of course, use it for your own resource groups if you ever have some. In that case you'll get an orxEVENT_TYPE_RESOURCE event with IDs letting you know what happened: orxRESOURCE_EVENT_UPDATE/orxRESOURCE_EVENT_ADD/orxRESOURCE_EVENT_REMOVE, but that's pretty advanced use of the resource system. :)

As usual, if you have any questions, please don't hesitate! =)

Cheers,

Rom

faistoiplaisir

unread,
Nov 1, 2013, 12:22:05 PM11/1/13
to orx...@googlegroups.com
Again, good news !

By hot reloading spawner's config, you mean that a change in any config's parameters, like WaveDelay, Object, will be applied immedialty ? All spawner's properties ?

Maybe hot reloading on FX and Animation can be very usefull too.

Thank you!

Gilles Zucchini

unread,
Nov 2, 2013, 7:05:44 AM11/2/13
to orx...@googlegroups.com
Hi,

I just tried to add a WatchList on the spawner tutorial without sucess ^^.

In orxResource.c, line 1151, the config module doesn't see my WatchList propertie ... (orxConfig_HasValue return false).

If I manually set the next instruction to force registering the callback it works perfectly.

In the config (11_Spawner.ini), I added WatchList = Config under the resource section, like that :

[Resource]
Texture = ../data/object
WatchList = Config

After some search ...... :

I think it's because this tutorial do some special config loading/clearing ? :

  /* Clears all config data */
  orxConfig_Clear();

Without this clearing config instruction, the watchlist is working fine (ie callback registered). 

Do you have an idea on how to solve that ?

Cheers & Thanks




2013/11/1 faistoiplaisir <faistoi...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "orx-dev" group.
To post to this group, send email to orx...@googlegroups.com.
Visit this group at http://groups.google.com/group/orx-dev.

iarwain

unread,
Nov 5, 2013, 11:43:53 PM11/5/13
to orx...@googlegroups.com
Yes, it's more an issue with how that tutorial is architectured. I'll have to update that one of those days. :)

As for other types, such as FX, animation or objects, it's more tricky as they imply deeper changes in memory that are not trivial. I'll see what I can do in the future.

And yes for the spawners, all the fields will get re-evaluated (actually the whole internals of the spawners will get re-created). There might be bugs with that feature too, lemme know if you find some others.

acksys

unread,
May 21, 2014, 11:39:50 PM5/21/14
to orx...@googlegroups.com
This will be awesome as I'm trying to get into shaders.

It's not working for me with the Mac nightly. I put an object with a shader in a config file in a skeleton project and added this to the main config file:

[Resource]
WatchList = Config

I change the shader code, but the result doesn't change. It changes when I stop and start the game again, though.

Just getting back to orx after a long hiatus. Once I get a good debugging setup on my Mac, I'll give more details.

orx-project

unread,
May 22, 2014, 1:28:29 AM5/22/14
to orx...@googlegroups.com
Ah, good to know.
It works for me on windows (I'm using it on Little Cells), but I
haven't tried it on mac/linux.
I'm also using the thread branch and not the default one (which is the
one you get with the nightly builds).

Can you tell me if you get the same problem when using the thread branch?

acksys

unread,
May 22, 2014, 2:16:17 AM5/22/14
to orx...@googlegroups.com
Yep, I will get you that info tomorrow.

I figured out how to set breakpoints in the dylib using lldb console. That's the best way I've found so far. So I'll be able to debug into the orx dylib.

acksys

unread,
May 22, 2014, 9:41:58 PM5/22/14
to orx...@googlegroups.com
Don't mind me. It was a dumb mistake on my part. I was modifying the .ini in the source directory and wasn't thinking about the fact that orx is watching the one in the same directory as the executable instead.

Now that I'm doing it right, the shader reloads. What a cool feature :)

FaeryFinn .

unread,
May 22, 2014, 9:45:30 PM5/22/14
to orx...@googlegroups.com

I'm glad it works. I've seen some inconsistent results (as in more or less broken visual result) with shader hotloading however, but never got any good repro case.
If you find one, let me know.

The feature looks pretty stable when it comes to config, texture, sound, etc, it's just with shader.

acksys

unread,
May 22, 2014, 10:32:26 PM5/22/14
to orx...@googlegroups.com
I'll let you know after I play with shaders some more. I also added info about the WatchList key to the wiki: http://orx-project.org/wiki/en/orx/config/settings_main/main?&#resource_module

orx-project

unread,
May 23, 2014, 12:09:12 AM5/23/14
to orx...@googlegroups.com
Excellent idea, thanks!
Reply all
Reply to author
Forward
0 new messages