How to change the region of windowed D3D8 device

Started by
17 comments, last by Opalm 19 years, 7 months ago
Thank a lot for all your suggestions. I will try your method ASAP.
In addition, I found that this problem can be solved by changing the create parameters of D3D device, when I use the following code,
-------------------------------------------------
D3DPRESENT_PARAMETERS d3dparam;
d3dparam.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC/* or D3DSWAPEFFECT_COPY */;
-------------------------------------------------
the 3D scene do not zoom in/out any more when I resize the window. But when I refer to the MSDN online, it dose not describe the difference between
(D3DSWAPEFFECT_COPY,D3DSWAPEFFECT_COPY_VSYNC) and(D3DSWAPEFFECT_FLIP, D3DSWAPEFFECT_DISCARD) on this aspect. Would you please give me your advice? Thanks again!
Advertisement
never seen or heard of D3DSWAPEFFECT_COPY_VSYNC before (??), it's not in the docs. But the sdk docs do explain the difference between COPY, DISCARD and FLIP very nicely, see the D3DSWAPEFFECT enum in the docs. It's all there.
[size=2]aliak.net
IFooBar--When I using SetViewPort, the 3D scene is stretched when resizing the window, I am wondering whether the SetViewPort has both clipping and scaling function?
but I just want to get the clipping effect, how can I do?
The reason your scene stretches when you resize the window is because the backbuffer is actually still the same size as the previous window size. So it has to be stretched into the new window size. Unless of course you reset the device and change the size of the back buffer. Have you tried doing that? Catch the WM_SIZE message in your window handle, calculate the new window size using GetClientRect and then set the new backbuffer size and reset the d3d device.

Also ont forget to change your projection matrix to math the new screen aspect ratio.
[size=2]aliak.net
Thank you!
You described very clarity, I deem that is the solution.

But to reset the device and change the back buffer size might reduce the efficiency, I think windowed mode is not suitable. Thus I should try another approach for the effect I wanted.
Quote:Original post by Opalm
But to reset the device and change the back buffer size might reduce the efficiency, I think windowed mode is not suitable. Thus I should try another approach for the effect I wanted.


While resetting does take up time, it is not something that is always done so it's no big deal. THe user isnt going to be resizing the window continuously right? s/he will probably size it once or twice to get the size that s/he likes, and resetting the device twice just for that is not unefficient, it's necessary if you don't want stretching to occur.
[size=2]aliak.net
From my understanding, the WM_SIZE message is called continuously whilst the window is being resized. This is probably not the best message to catch and use.

You may wish to try catching the WM_WINDOWPOSCHANGED message and check the resulting structure returned in LPARAM against the previous values for width and height, and only reset if the size has changed.
Yes, Thanks for your kindly hint, it's really a effectual method to reduce the frequency of D3D device reset.

This topic is closed to new replies.

Advertisement