DirectX devices (dependent or not) on the back buffer

Started by
5 comments, last by BlessmanTsanga 12 years, 6 months ago
hi

Which types of direct x devices are dependent on the back buffer? and which are not? Is it as simple as that "if it relates to rendering- then it is" or else it wouldn't be?

Sorry if this seems like a stupid question but, I've been stressed over my direct x project today.
Advertisement
I don't quite follow - In order to create a device, you need to create a backbuffer (Assuming DX9). Therefore all devices depend on the backbuffer.

There's nothing to stop you creating a 1x1 pixel backbuffer, however.

I don't quite follow - In order to create a device, you need to create a backbuffer (Assuming DX9). Therefore all devices depend on the backbuffer.

There's nothing to stop you creating a 1x1 pixel backbuffer, however.


Basically I'm a bit confused about this:



/--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
return S_OK;
}


//--------------------------------------------------------------------------------------
// Create any D3D10 resources that depend on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10ResizedSwapChain( ID3D10Device* pd3dDevice, IDXGISwapChain* pSwapChain,
const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
return S_OK;
}


Whats confusing me is the purpose (or the difference) between these two functions. These are provided as part of the "emptydirectx10" project and I've been trying to build up on it for the past 6 hours; then only to have the compiler reject it. sad.gif(has been quite a stressful day of trying to learn)
I think the separation is there because when the screen resizes, you will want to resize your back buffer. Any thing that may change based on the back buffer being resized will need to be recreated. If it does not depend on the back buffer being resized, then you can create it in the other procedure. That is just my guess though.



only to have the compiler reject it.


What is the compiler error, exactly?
In D3D10 and D3D11 the backbuffer and the device are separate, it's perfectly valid to have a D3D device with no backbuffer if you never need to present to the screen (for instance, if you only want to render and save an image to file). Creating a backbuffer is done by creating a swap chain, which binds a backbuffer to a particular window.

So that first DXUT callback only gets called at the very beginning of your app when the device is created. The second DXUT callback is called when the swap chain is first created, and also whenever the window is resized (and subsequently, the backbuffer is resized). So for instance in the first callback you might load shaders, models, and textures since they're not dependent on the size of the backbuffer. However if you wanted to create a render target that's half the size of the backbuffer for some fullscreen effect, you would want to do that in the swap chain resize callback.
ok thanks but now I've got an issue with loading in my shader:



D3DX10CreateEffectFromFile(L"Mazuma_shader", NULL, NULL, "fx_4_0", dwShaderFlags, 0 ,g_pd3dDevice, NULL,
NULL, &g_pEffect, NULL, NULL );



Basically I copied the way I to import a shader, to my project, from one of the windows tutorials where I also copied and pasted the shader file (but changed its name). And afterwards I included it in my project using the "add existing file" importer (its in the same folder as my project too), but when compiling it tells me that it can't find my shader file.

How can I include my shader in other ways?

This topic is closed to new replies.

Advertisement