Is Viewport a good alternative to RenderTarget CPU wise? My use case is showing items outside of the screen area at the edge of the screen, like waypoint arrows but with the actual gfx scaled down to fit inside an arrow.
If you would have refreshed your RenderTarget each frame, then yes Viewport will be more efficient, not CPU wise but GPU wise. You save the need for draw your render target on screen.
The reason is that with render target you have to first render to the texture, then render the texture onto the screen. With the viewport you point to your list of sprites then put the viewport on the screen.
A disadvantage is that viewports cannot be rotated (as far as I know, I might be wrong), but a render target can be as it's a regular sprite.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@hgy29, so I can have a viewport that is a square, but tilted by 45 degrees and the clipping will work ok so that it looks like a diamond shape on the screen?
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@SinisterSoft, no you can't because clipping only works with screen axis aligned rectangular regions. This is not a viewport limitation however, but rather a clipping one.
I'd have to render it to a rendertarget then show that sprite on the screen then.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
The reason is that with render target you have to first render to the texture, then render the texture onto the screen. With the viewport you point to your list of sprites then put the viewport on the screen.
A disadvantage is that viewports cannot be rotated (as far as I know, I might be wrong), but a render target can be as it's a regular sprite.
https://deluxepixel.com
https://deluxepixel.com
https://deluxepixel.com