• Breaking News

    Game Engine API, smart pointers or not? Hi, I'm writing a game engine, when my API returns a pointer, most of the time it is meant to be used and then discarded right away. But I have some things where it might be useful to store the pointer. E.g. addNewGameObjectToScene. It would create a new object, add it to the scene, and return a pointer. But there is one obvious problem, there is no way to check if the returned pointer is valid. Because the newly created object could be deleted at any point, and then the pointer is invalid and using it would cause crashes. Therefore, to me it would make sense to use smart_pointers to fix that. But have found that not everyone agree's with me on that.(And I personally don't like to use smart pointers in api if I can avoid it) So what do you guys think? If I should use raw pointers, how would I fix the issue, and if I should use smart pointers, will it impact performance or drive people away from using my api? Thanks! https://ift.tt/eA8V8J

    Hi, I'm writing a game engine, when my API returns a pointer, most of the time it is meant to be used and then discarded right away. But I have some things where it might be useful to store the pointer. E.g. addNewGameObjectToScene. It would create a new object, add it to the scene, and return a pointer. But there is one obvious problem, there is no way to check if the returned pointer is valid. Because the newly created object could be deleted at any point, and then the pointer is invalid and using it would cause crashes. Therefore, to me it would make sense to use smart_pointers to fix that. But have found that not everyone agree's with me on that.(And I personally don't like to use smart pointers in api if I can avoid it) So what do you guys think? If I should use raw pointers, how would I fix the issue, and if I should use smart pointers, will it impact performance or drive people away from using my api? Thanks!

    from GameDev.net http://bit.ly/2UsHvVi

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728