Skip to content

Commit 82c630a

Browse files
authored
IID_PPV_ARGS elaboration (1-1-2) and 1 other thing (#113)
* explain IID_PPV_ARGS add clarity to description clear up that uuidof returns REFIID and why * update explanation to be more in depth adjusted to follow the request of Alex: talk more about what a GUID and UUID is earlier in the explanation, and include a more accurate explanation of what IID_PPV_ARGS does without bloat after the fact since I explain earlier the whole GUID<->UUID<->why-it-matters-paradigm * implement changes requested * The removal of Helper explanation and grammar
1 parent 1ef4167 commit 82c630a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

docs/1-introduction/1-1-getting-started/1-1-2-hello-d3d11.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ We need to include the following headers, here's what each of these headers incl
142142
#pragma comment(lib, "dxguid.lib")
143143
```
144144

145-
Of course just including the headers isn't enough, we must also link against D3D11 & friends to be able to actually use the stuff declared in the headers, put these `#pragma` in `HelloD3D11.cpp` right below the includes.
145+
Of course just including the headers isn't enough, we must also link against D3D11 & friends to be able to actually use the stuff declared in the headers, put these `#pragma comment(lib, "PATH_TO_LIB")` in `HelloD3D11.cpp` right below the includes to link these libraries.
146146

147147
```cpp
148148
template <typename T>
@@ -192,7 +192,29 @@ if (FAILED(CreateDXGIFactory2(
192192
193193
The first part calls the parent class, where `GLFW` is initialized and setup.
194194
195-
!!! error "What is `IID_PPV_ARGS`"?
195+
`IID_PPV_ARGS(ppType)` Is a compile time macro that is defined as
196+
```cpp
197+
#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)
198+
```
199+
Which means that typing `IID_PPV_ARGS(&_dxgiFactory)` it is expanded by the compiler into `__uuidof(**(&_dxgiFactory)), IID_PPV_ARGS_Helper(_dxgiFactory)`. This functionally means that for functions that have a parameter setup as `REFIID` and functionally after a `[out] void**` parameter, this macro will expand the `IID_PPV_ARGS(ppType)` expression into these parameters for ease of use — this can be seen with the used `CreateDXGIFactory2` method where the second last and last parameter are a `REFIID` and `void**`:
200+
```cpp
201+
HRESULT CreateDXGIFactory2(
202+
UINT Flags,
203+
REFIID riid,
204+
[out] void **ppFactory
205+
);
206+
```
207+
`REFIID` is a typedef that is a Reference (REF) to an Interface Identifier type (`IID`) — this means that it is a reference to a type that uniquely identifies a [COM](link-to-com-subsystem-in-msdn) object.
208+
[more information like underlying memory organization can be read about IID's at https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/iid]
209+
210+
211+
What the parts of the `IID_PPV_ARGS(ppType)` macro are:
212+
213+
[the `ppType` in `IID_PPV_ARGS(ppType)`]
214+
- a pointer to a pointer of a object.
215+
216+
[the `__uuidof(**(ppType))` part of `IID_PPV_ARGS(ppType)`]
217+
- at compile time retrieves a `UUID` from `ppType` type which represents a `GUID`, which is returned as a `REFIID` — which means that the type returned is a reference to an identifier to a specific type of COM object.
196218

197219
!!! error "Explain DXGI"
198220

0 commit comments

Comments
 (0)