Sign in to follow this  
BlessmanTsanga

DirectX devices (dependent or not) on the back buffer

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='Evil Steve' timestamp='1318523949' post='4872237']
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.
[/quote]

Basically I'm a bit confused about this:


[code]
/--------------------------------------------------------------------------------------
// 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;
}
[/code]

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. [img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img](has been quite a stressful day of trying to learn)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ok thanks but now I've got an issue with loading in my shader:


[code]
D3DX10CreateEffectFromFile(L"Mazuma_shader", NULL, NULL, "fx_4_0", dwShaderFlags, 0 ,g_pd3dDevice, NULL,
NULL, &g_pEffect, NULL, NULL );[/code]


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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this