Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

The best way I’ve realized to implement an asset supervisor is having unordered maps for every asset sort (textures, shaders, meshes, and so forth.), every with a string key and object worth after which having strategies Add(), Get(), Load() for every asset sort. For my ability degree and the dimensions of tasks I will be doing that is in all probability adequate, nevertheless, I got here throughout a weblog that makes use of the idea of handles which I discovered fairly fascinating. It reveals a deal with as a wrapper round a uint32_t after which goes on a few supervisor class that follows the same construction to what I mentioned.

What I do not perceive about this strategy is how do you affiliate a deal with with a object? With the tactic I have been utilizing because it’s simply strings I can simply create an object and retailer the ID in it

AssetManager::AddTexture("Textures/participant.png", "PlayerTexture");
AssetManager::AddMesh("Meshes/participant.obj", "PlayerMesh");

// This might technically be written anyplace
Scene::AddObject(GameObject("Participant", "PlayerTexture", "PlayerMesh"));

AssetManager::GetMesh(Object.MeshName);

static Mesh GetMesh(std::string ID) {
    return  meshes[ID];
}

However with handles would not I must make my object proper after loading the asset? Or how else am I purported to get the deal with to the article until I proceed to make use of string IDs however for the handles, however I really feel like that may defeat the aim. Here is an instance of making an attempt to grasp utilizing handles.

TextureHandle playerTextureHandle = AssetManager::AddTexture("Textures/participant.png");

// Must be right here so I can entry the variable
Scene::AddObject(GameObject("Participant", playerTextureHandle));

AssetManager::GetTexture(Object.textureHandle);

struct TextureHandle {
    unsigned int deal with;
}

static Texture GetTexture(TextureHandle deal with) {
    return textures[handle.handle];
}

Penning this put up one other potential drawback may be the very fact I do not perceive what a deal with absolutely is so I’ve a sense I won’t be utilizing it within the supposed manner.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *