2 rendertarget onto one Spritebatch?

I know that this seems weird, but I need (or I think I need) to do this for a reason.

In my game, I make a zoom in the screen for “recreating” the advancing sensation in a dungeon (first person 2D game). The problem is, I want to make a HUD with a minimap, health and that info, and if I make zoom, it will zoom the entire screen.

What I want to do, is to have a RenderTarget for the scenario (dungeon), and another for the HUD, and then show it together in the sprite batch. Is this possible?

Yea, draw each stuff to both render targets.

spriteBatch.Begin()
spriteBatch.Draw( // RT one)
spriteBatch.Draw( // RT two)
spriteBatch.End()

That is a simplistic scenario if I understand right you may want to zoom the rt one but not two. I am not 100% sure but something like this may work

spriteBatch.Begin(cameraTransformation)
spriteBatch.Draw( // RT one)
spriteBatch.End()

spriteBatch.Begin()
spriteBatch.Draw( // RT two)
spriteBatch.End()

It seems that I can’t do it that way ó_o

What is null, the RT or the screen rectangle on the second run?

AH, I didn’t say nothing. I wasn’t initializing the rendertarget properly.

Now it works perfectly!

1 Like

Nice one,

Do you just apply camera transformations to the first RT then?

Yup, as I only wanted to make zoom on that concrete RenderTarget.

Nice one glad it works as simple as that lol, at some point I will be doing the same. (well similar, 2D side scroller with hud/map)