Hgawmphdmph Posted August 30, 2021 Share Posted August 30, 2021 Hi all, I'm in the process of converting key parts of my partially written framework using Leadwerks from Lua into C++ and I have a question about loaded assets and memory management. Looking at things like the CreateNew load parameter, the Asset path attribute and the Copy function, I'm guessing that if I load the same asset more than once, the API will just return a pointer to the existing instance already loaded, in order to save memory - is that correct? If so, my real question is, what happens if I load a Texture from C++ and then load the same one again from my Lua code. Will the API return a Lua table pointing to the original asset? Alternatively, is there some way of accessing a C++ loaded asset or entity from Lua or Lua table of an asset or entity from C++? Last time I tried this I got an access violation. Cheers and thanks in advance, Colin Quote Link to comment Share on other sites More sharing options...
Josh Posted August 30, 2021 Share Posted August 30, 2021 37 minutes ago, Hgawmphdmph said: Looking at things like the CreateNew load parameter, the Asset path attribute and the Copy function, I'm guessing that if I load the same asset more than once, the API will just return a pointer to the existing instance already loaded, in order to save memory - is that correct? Yes. It doesn't matter if the load command is called from C++ or Lua. The engine uses the same routine to check for the loaded asset by file path. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Hgawmphdmph Posted August 30, 2021 Author Share Posted August 30, 2021 Hi Josh, That's brilliant, thanks so much for such a quick reply. (Absolutely love Leadwerks by the way. Best engine I've ever used.) Cheers, Colin 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.