[tangential but useful:]
While on the topic of simplifying object management (using maps, etc), you might also want to consider using CComPtr to manage all your COM interfaces (DirectX). You''ll never have to call Release or write another SAFE_DELETE macro again. It''s in the <altbase.h> header file, and is a real time saver. You can stick references to them in your map if space is an issue.
Stl question
Oluseyi- while looking for solutions and such in the forums, i''ve seen you talk about the CComPtr(). i''ve read up on it, but i''m not sure how to apply it correctly in my case. In other words, how would you implement into the code correctly?
quote:Original post by Pactuul
Oluseyi- while looking for solutions and such in the forums, i''ve seen you talk about the CComPtr(). i''ve read up on it, but i''m not sure how to apply it correctly in my case. In other words, how would you implement into the code correctly?
In general, you would use CComPtr like so:
CComPtr <IInterface> interface;CoCreateInstance(..., &interface);// Don''t call Release; CComPtr will call it for you when interface goes out of scope
Keep in mind that you can''t generally use CComPtr in containers because it overloads operator &. I had a big problem with std::vector''s of CComPtr''s of IDirect3DTexture8''s due to this; check my profile for the thread link. There are some code snippets in that thread as well.
HRESULT hr;CComPtr <IInterface> pInterface;if(FAILED(hr = pInterface.CoCreate(CLSID_CoInterface))) return hr;pInterface->InterfaceMethod(...);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement