Monday, February 11, 2019

assets - How should I handle missing resources?


Your game expects a certain asset to be loaded, but it isn't found. How should the situation be handled? For example:


Texture* grassTexture = LoadTexture("Grass.png"); // returns NULL; texture not found
Mesh* car = LoadMesh("Car.obj"); // returns NULL; 3D mesh not found


It might have been accidentally deleted by the user, corrupted or misspelled while in development.


Some potential responses:



  • Assertions (ideally only during development)

  • Exit the game gracefully

  • Throw an exception and try to handle it.


Which way is best?



Answer



Lots of games have a generic "error material" and "error mesh" that is really obvious to see. Pair this with a warning in the logs, of course.



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...