Sign in to follow this  
jbb

Offscreen rendering (d3d9)

Recommended Posts

For a small program I want to be able to render a scene to an offscreen buffer and the output it to a file. There is no display window at all. I have no problem doing this by calling dev->CreateRenderTarget and SetRenderTarget and then using D3DXSaveSurfaceToFile. However to get the device to do this I need to create a device and they are attached to a window. This seems unnecessary so I was wondering if there is any way to avoid this step and only have the offscreen surface to render to? If it is necessary, I seem to get away with putting almost anything for the present parameters I use to create the device, I zero the structure then set the back buffer dimensions to 512,512, Windowed to true and Swap effect to D3DSWAPEFFECT_DISCARD, but I'm just passing 0 as a hwnd ... It all seems to work but I'm not sure if I'm breaking something badly. My application doesn't actually have an application, it's a console window. Is there a proper way to do this that I'm missing or is the "hack" I have acceptable and safe?

Share this post


Link to post
Share on other sites
I don't think you can avoid making a device as that's just the way it works. However, if you want it to just work and not be susecptible to driver failures, you should look in the docs about creating a NULLREF device. I don't know how much functionality that gives you as I never used it, but the word tends to crop up in the conversations on the DX mailing list.

Share this post


Link to post
Share on other sites
NULLREF is a software device that doesn't render, so won't do much good for your purpose.

In Direct3D 9 you have to have a window. Just make one that's invisible, and you can do it from a console app. See for example my sample here. In Direct3D 10 you can create a device without a window (the sample also has an example of that).

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