Jump to content

Recommended Posts

Posted

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

Posted
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.

Let's build cool stuff and have fun. :)

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...