Jump to content

  • Log In with Google      Sign In   
  • Create Account

StretchRect() in DX11?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 DarkRonin   Members   -  Reputation: 616

Like
0Likes
Like

Posted 02 July 2014 - 11:42 PM

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 smile.png

Sponsor:

#2 unbird   Crossbones+   -  Reputation: 6020

Like
7Likes
Like

Posted 03 July 2014 - 12:12 AM

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.

#3 DarkRonin   Members   -  Reputation: 616

Like
0Likes
Like

Posted 03 July 2014 - 12:47 AM

Thanks for the reply unbird smile.png

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 smile.png

Edited by DarkRonin, 03 July 2014 - 12:49 AM.


#4 unbird   Crossbones+   -  Reputation: 6020

Like
1Likes
Like

Posted 03 July 2014 - 01:44 AM

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 biggrin.png

Edited by unbird, 03 July 2014 - 01:45 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS