Hello all,
I'm working on my first game project and am trying to wrap my head around how best to use exceptions and error codes. In particular, what gets me is not being entirely sure about how to handle construction of objects that make DirectX calls.
On Mike's book, p. 206 "Exception Handling" addresses this issue by throwing a custom error exception. I've seen other texts such as "C++ for Game Programmers" by Noel Llopis refer to the idea of using smart pointers to hold all pointers so memory leaks are avoided.
For example, if I'm creating a renderable object, it will probably hold a pointer to a DirectX texture (LPDIRECT3DTEXTURE8). If this is initialized during construction, but some other later step fails and an exception is thrown, aren't I at risk of leaking this memory for the texture? (assuming my class holds a private member variable LPDIRECT3DTEXTURE8)
Thanks for the great book Mike, and thanks all for your advice!
Cheers,
Dan
I'm working on my first game project and am trying to wrap my head around how best to use exceptions and error codes. In particular, what gets me is not being entirely sure about how to handle construction of objects that make DirectX calls.
On Mike's book, p. 206 "Exception Handling" addresses this issue by throwing a custom error exception. I've seen other texts such as "C++ for Game Programmers" by Noel Llopis refer to the idea of using smart pointers to hold all pointers so memory leaks are avoided.
For example, if I'm creating a renderable object, it will probably hold a pointer to a DirectX texture (LPDIRECT3DTEXTURE8). If this is initialized during construction, but some other later step fails and an exception is thrown, aren't I at risk of leaking this memory for the texture? (assuming my class holds a private member variable LPDIRECT3DTEXTURE8)
Thanks for the great book Mike, and thanks all for your advice!
Cheers,
Dan
The post was edited 1 time, last by etldan ().