Jump to content
  • Advertisement
Sign in to follow this  
pas059

Window resizing

This topic is 2507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm porting an MDX application to SlimDX (targetting Direct9). Everything seems to goes fine, except when i resize the window (a Windows.Form) and so the Control it contains. Every parts are just stretched.
In the overrided OnResize() method of the Control, i tried to redefine the Viewport of my Device, but without success; i also tried to call the Reset() method of the device but this gives an D3DERR_INVALIDCALL exception.

Someone can tell what must be done to correct this problem?

thanks in advance,
Pascal

Share this post


Link to post
Share on other sites
Advertisement
You need to reset the device for Direct3D 9, however, in order to reset it you must also provide proper arguments and clean up existing resources.

However, there is a better way if you intend to resize it a lot, I don't have the code right now, but what you do is make the primary backbuffer 1x1 and instead create your own backbuffer to replace the default one, your own backbuffer can now be recreated without resetting the device.

Share this post


Link to post
Share on other sites
Hi Syranide,

I tried to Reset the device and the parameters are correct, but i always get en exception D3DERR_INVALIDCALL.

Someone can gives a code sample?

thanks in advance,
Pascal,

Share this post


Link to post
Share on other sites
In general, any resources you've allocated that required passing in the Direct3D9Device need to be be freed before calling Reset(). In reality it depends on the resource pool used, but more than likely you've used the default pool, which requires explicit freeing of the resource.

My screen resize code does the following:

1) Free all resources
2) Update the backbuffer size
3) Reset the device
4) Load all resources (if required).

Share this post


Link to post
Share on other sites
Hi Postie,

Do you mean that objects like VertexBuffer, Mesh have to be freed? and then recreated after updating? this can take many time in some cases.

As it was not necessary to do this in MDX, i'm suprising.

Do you have a link?

thanks again,

Pascal

Share this post


Link to post
Share on other sites

Hi Postie,

Do you mean that objects like VertexBuffer, Mesh have to be freed? and then recreated after updating? this can take many time in some cases.

As it was not necessary to do this in MDX, i'm suprising.

Do you have a link?

thanks again,

Pascal


Sadly that is the case, with Direct3D 9, Direct3D 9Ex does not require it I believe.
Anyway, as above, you can create your own backbuffer to replace the default one, that backbuffer can then be recreated at will without resetting the device. I don't know what MDX is really, but I would assume it's using one of the above.

Share this post


Link to post
Share on other sites
Hi again,

Indeed, after disposing ressources resetting the device no longer generates an exception (of course), but as recreating all can takes times (in some cases) the solution consisting on recreating the backbuffer seems more elegant to me.
But, i haven't seen how to create a backbuffer with SlimDX/D3D9.
Do you have an example, a link,...?

thanks in advance
Pascal

Share this post


Link to post
Share on other sites
Hi,

i tried this by Disposing the BackBuffer, then to recreate one with the new Size, but this gives the same result. Concerning the SwapChain, it can not be created directly. On the link you give, Syranide, this is also what they observed, and then they concluded that the "Elements" have to be recreated. I saw in the SlimDX sample that this is also the method they used.
If you could show us your code, this would nice.

Thanks again,
Pascal

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!