some D3D11 beginner questions

Started by
0 comments, last by MarcusAseth 6 years, 9 months ago

Hi everyone, I've randomly found this place trough google and this is my first post, I don't know if my beginner level is still too low even for the beginners sections therefore if it is, my first question would be to point me in the right place where I should ask my questions :)

And if is ok, then this is my next question:

I'm going trough the book "3d Game Programming with DirectX 11" and in the process of creating a swapChain I'm staring at this code below


IDXGIDevice* dxgiDevice = 0;
HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));

IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**))&dxgiAdapter));

IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**))&dxgiFactory));

IDXGISwapChain* mSwapChain;
HR(dxgiFactory->CreateSwapChain(md3dDevice, )&sd, )&mSwapChain));

 

From my understanding, in order to create a swapChain we need to use the same Factory used to create our Device otherwise for some reason everything explodes, therefore the call to QueryInterface() and the two calls to GetParent() are meant to give me back a pointer to said Factory.

Question 1): Now I'm watching msdn and a IDXGIDevice has a GetAdapter() method in it, so I was wondering, using it would achieve the same as the line

"dxgiDevice->GetParent(__uuidof(IDXGIAdapter),(void**))&dxgiAdapter));" or is a completely different thing?!

Question2): Not much further in the book, the writer do this "mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer));"  so now we're using a reinterpret_cast and not "(void**)". Why this change? I am not very familiar with the different types of cast, so I can't tell the difference or the reason behind it x_x

Also can you recomend me let's say a youtube video or some reading that properly illustrates the structure of Direct3D? Because I am kind of confuse about what is going on here, the whole hierarchy of this thing and basically I don't have a clear picture of how all the pieces fit togeter... :/ 

Thanks :)

This topic is closed to new replies.

Advertisement