-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-08-06 um 00:49 schrieb Aaryaman Vasishta:
device->d3drm = d3drm;
- device->render_target = surface; IDirect3DRM_AddRef(d3drm); device->render_target = surface;
This is redundant.
hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
IDirectDrawSurface_Release(ds);
if (FAILED(hr))
return hr;
- }
You've overshot my suggestion for pre-attached depth stencils a bit. Now you no longer detach application-created depth stencils any more in case CreateDevice() fails, but you also don't detach a depth stencil that you attached.
This may even be the correct behavior. If you want you can write a test (e.g. try to pass a color surface without DDSCAPS_3DDEVICE, but *with* a depth stencil attached. See if it is detached. Try to pass a color surface without DDSCAPS_3DDEVICE and see if a depth stencil is attached after the failing CreateDevice call), but I don't think it's worth spending much time on this.
My suggestion is to detach if creating the IM device fails, but only if create_z_surface is TRUE.