0

I am new to DirectX11 and learning it. (I come from openGL background).

I am confused and trying to understand what exactly does the following API calls do and what is the difference between them:

ID3D11Texture2D* pBackBuffer = NULL;
hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );

and

hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
pBackBuffer->Release();

What does GetBuffer really do ? How are we then using the pBackBuffer in CreateRenderTargetView ? Also, can someone explain or point me to a link that explains, what is a render target view ? The msdn doc didn't make much sense to me.

brainydexter
  • 19,826
  • 28
  • 77
  • 115

1 Answers1

1

As i recall, the GetBuffer() returns the pointer to the internal backbuffer that devices use. your then from there create a RenderTarget that you can bind as your "Real backbuffer" target.

think of it as : pBackbuffer = glBindFramebuffer(GL_FRAMEBUFFER, 0);

thats how i remember it. ( was some time ago i did this with dx11 )

edit* And a rendertargetview, is a framebuffer. it´s a texture that you can bind to be read and writen to.

TheMonkeyMan
  • 8,622
  • 8
  • 27
  • 42
Tordin
  • 340
  • 1
  • 10
  • So, if I understand this correctly, `getBuffer` returns the pointer to actual buffer. `CreateRenderTargetView` makes this buffer a render target (aka Framebuffer) which is then bound to in the rendering pipeline. PS: RenderTargetView doesn't create another buffer. – brainydexter Oct 04 '12 at 12:09
  • 2
    Yes, instead of returning a int (like opengl dose) you have to create a interface from it. they just like to call it with fancy names! – Tordin Oct 04 '12 at 12:13
  • ha ha, yeah I couldn't agree more! – brainydexter Oct 04 '12 at 12:29
  • Please note that you can't read from RenderTargetView, for that you need to create a ShaderResourceView. @Tordin we all like fancy names )) – mrvux Oct 04 '12 at 14:50