Hi Guys,
Previously when I used DX9c I used to draw to a surface of a preset size (usually screen dimensions 1600x900) and when I went into windowed mode I would simply draw the surface to the window using...
(FAILED(d3dDevice->StretchRect(surfaceApplication,NULL,surfaceBackbuffer,&DstRect,D3DTEXF_LINEAR )))
So, this way the scene would resize gracefully and I could still move objects as if they were still in full screen dimensions.
Is there a way to do similar in DirectX 11?
Thanks in advance
StretchRect() in DX11?
Not with a simple function call, no. You render to a texture and then draw a full screen quad (or whatever dimension you like) and a pixel shader simply sampling said texture. The texture needs to have both D3D11_BIND_SHADER_RESOURCE and D3D11_BIND_RENDER_TARGET for BindFlags and you create ID3D11ShaderResourceView and ID3D11RenderTargetView to use for this scenario. Make sure you unbind one view first before using the other, the pipeline disallows simultanous read/write and will nullify such an attempt.
On the other hand, you can achieve the same more directly with a proper camera/viewport/coordinate system which accounts for the output dimension.
On the other hand, you can achieve the same more directly with a proper camera/viewport/coordinate system which accounts for the output dimension.
Thanks for the reply unbird
Makes sense what you are saying.
The camera system suggestion is an awesome one, I didn't even think of adjusting that.
I allready have an OrthoGraphic camera setup in my project, I tried adjusting the camera's window width and height, and what do you know 'it just works!'.
I was ready to have a hell of a time to get this working and it was easy in the end. So, it just goes to show some decent advance planning does pay off sometimes ;)
[edit]
This will allow for all sorts of awesome zoom effects also! You have made my day
Makes sense what you are saying.
The camera system suggestion is an awesome one, I didn't even think of adjusting that.
I allready have an OrthoGraphic camera setup in my project, I tried adjusting the camera's window width and height, and what do you know 'it just works!'.
I was ready to have a hell of a time to get this working and it was easy in the end. So, it just goes to show some decent advance planning does pay off sometimes ;)
[edit]
This will allow for all sorts of awesome zoom effects also! You have made my day
Indeed. A flexible 2D camera is not only a good exercise in transformations, but since it results in changing only one matrix (usually) for the shader - which you do need anyway - it is practically free on the GPU side. Drop those magic numbers!
Glad you got it already
Glad you got it already
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement