Shane
Shane

Reputation: 379

XNA 4.0 Security Camera Feature

I'm looking to make a security camera type feature in a game I want to design. The idea that I have is that there will be a designated rectangle similar to a TV screen in the game and I want to be able to display in that rectangle area what a Camera sees in a specific room.

So to setup a specific scenario, let's say we have Room A and Room B. I want in Room B to be a TV Screen that displays what is currently shown in Room A. I know this must be possible some how using the XNA camera functions, I'm just really unsure how I would output what the camera sees in that area and then show it in the designated sprite rectangle in Room B.

Hopefully this makes sense or is possible :D

TKs, Shane.

Upvotes: 1

Views: 99

Answers (1)

Kendall Frey
Kendall Frey

Reputation: 44374

You will want to render your security camera scene to a custom RenderTarget2D, which you can then use as though it were a Texture2D.

The 5 basic steps to this are:

  • Create a custom RenderTarget2D
  • Tell your GraphicsDevice to render to this new target
  • Render your 'screen' scene
  • Reset the render target
  • Texture your screen polygon with the texture created by the render target

For more information, see Riemer's XNA tutorial.

Upvotes: 2

Related Questions