I am making a game engine and I am going to support both OpenGL and Direct2D. I heard that rendertargets can return an error on EndDraw(), needing to recreate every resource created with it. I was wondering if that happens frequently, should I handle that error and how does it happen. In OpenGL you don't lose a context just because so. So, what causes the loss of a render target and should I use direct2D for games even with this problem? Thanks in advance.
In the past (read DirectX 9 and earlier), a lost device usually occurred when you switched focus away from a full screen application. Then, during the time that your application was not visible, you had no graphics device to draw to. And when the focus was set back to your application, you had to re-initialize the device and all resources that were created on that device.
Today (DirectX 10 and beyond), this is not the case anymore. Access to the graphics device is virtualized, so you keep your device handle when the application loses focus. However, there are still a few cases when you can loose your device, e.g., physical changes to the computer, crash and reset of the driver, etc. So, the situations in which you loose your device are very rare and somewhat extreme. You can handle those situations if you want (and you should if you want to create a stable application), but the average user will most likely not run into any of these extreme situations. For more information, take a look at this MSDN article.