is there a faster way to change screen width and hight

Started by
6 comments, last by TheAdmiral 17 years, 3 months ago
this is my code, but its soo slow (following code works every "window sizing") var D3DPP:TD3DPresentParameters; D3DPP.BackBufferWidth:=windowWidth; D3DPP.BackBufferHeight:=windowHeight; D3DDevice.Reset(D3DPP); is there a faster method can you tell me? thanks
Advertisement
Since I'm assuming this is Delphi, which I'm not very familiar with, I'm not entirely sure, but I would speculate that you could also use a window size event instead of sizing. If you look at the Windows messages on which I'm guessing this event is based, you'll see that WM_SIZING happens continuously as a user resizes the window, but WM_SIZE happens only after the sizing is finished. I doubt you really need to continually resize your contents as the user resizes the window. It's only when they've determined a size they want that you really need to do this.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
thanks Agony, but WM_SIZE works continuously so device resets every mouse cursor move,
well if there was a message which working after the sizing is finished, could be great (so device resets only user released mouse button), but i couldnt find any message like that.

the point is : "reset" method working slowly, is there any way without "device.reset" code
There are messages something like WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE. You can use those, determine if sizing really did occur, not just a move, and then reset.

A faster reset is actually possible. Don't use the backbuffer and autodepthstencil surface. To save memory, set these to something small (like 1x1).

Use CreateAdditionalSwapChain to make a new backbuffer, and create a depth buffer to go along with it. Set this other backbuffer and depth buffer as your active (SetRenderTarget/SetDepthStencilSurface), Clear, and draw. When you need to reset, destroy and recreate a new swap chain. Because D3D doesn't need to do anything with managed vertex buffers, textures, shaders, etc, this is much faster. Pretty much instantaneous.

When using D3D's debug libraries, and possibly related to nVidia's drivers, people have had troubles with their depth surfaces not working correctly if they're larger than the depth surface created with the device. I've had this occur when making depth textures for shadowing, which is an nVidia specific thing. Not sure if depth surfaces suffer as well, but it's something to be aware of.
thanks ntnet,
look like you know many thing about direct3d,
i think i'm goingto use "WM_EXITSIZEMOVE" message, other way is too much for me (for now), thanks for explanation
Create a backbuffer the size of the entire screen, but set a viewport for the window. When the screen is resized you just have to change the viewport and the projection matrix. Wastes a little bit of memory, but if resize speed is important for you, this will give you almost instant resizes.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
thanks, thats a good method to
Quote:Original post by Raloth
Create a backbuffer the size of the entire screen, but set a viewport for the window. When the screen is resized you just have to change the viewport and the projection matrix. Wastes a little bit of memory, but if resize speed is important for you, this will give you almost instant resizes.

My biggest concern with this method isn't the memory consumption, but the fillrate hit. If your application is fillrate-limited (and very many are with today's lightning-fast vertex pipelines) this will strike you right at the bottleneck.

However, this is only one consideration. As it happens, I frequently use this method. Like you say, there is no stall when resizing the window. Also, it gives improved antialiasing by way of supersampling. Moreover, if your application is designed to run satisfactorily in a full-sized window, then it should be capable of rendering at this resolution anyway.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

This topic is closed to new replies.

Advertisement