Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinRT C++ ComPtr GetAddressOf vs &

I just got started with DirectX 11.1 for Windows 8 apps and I got the following ComPtr for example:

ComPtr<ID3D11Buffer> constantBuffer;

What I wonder is, what is the difference between using &constantBuffer and constantBuffer.GetAddressOf()?

Sometimes they both works fine, but sometimes using &constantBuffer will cause my program to crash with an access violation.

like image 441
Johan Falk Avatar asked Dec 22 '12 22:12

Johan Falk


1 Answers

Did you read documentation?

GetAddressOf - Retrieves the address of the ptr_ data member, which contains a pointer to the interface represented by this ComPtr.

Operator& - Releases the interface associated with this ComPtr object and then retrieves the address of the ComPtr object.

like image 81
nothrow Avatar answered Sep 28 '22 16:09

nothrow