Hi
I'm not sure if I understand you right, but what your're trying to do is something like splitscreen or a minimap? In that case what you have to do is render the scene to a texture and then display that texture on the screen.
| // Global definitions |
| Texture 2D tex; // the texture to render to |
| RenderTarget2D target; // the render target |
| const int texturesize = 512; // the size of the texture; change this for a higher resolution, but a too high resolution only uses more performance and if your render the texture onto the screen then it's useless to have a texture that has a higher resolution than the screen. |
| |
| // Initialize game |
| // ... |
| target = new RenderTarget2D(GraphicsDevice, texturesize, texturesize, 0, SurfaceFormat.Color); // create a new render target |
| // ... |
| |
| // Draw game |
| // ... |
| using (RenderTarget2D oldrendertarget = (RenderTarget2D)GraphicsDevice.GetRenderTarget(0)) // save the old render target, if you don't render normally at all (= only with textures) it's not really needed |
| { |
| GraphicsDevice.SetRenderTarget(0, target); // change the target |
| |
| // Your draw code for the first texture here |
| |
| GraphicsDevice.ResolveRenderTarget(0); // save the drawn image to the target |
| GraphicsDevice.SetRenderTarget(0, oldrendertarget); // sets the target back to the old one |
| } |
| tex = target.GetTexture(); |
| |
| spriteBatch.Begin(); |
| spriteBatch.Draw(tex, new Rectangle(x, y, width, height), Color.White) // render the image in the tex-variable directly to the screen |
| spriteBatch.End(); |
You could also make a special keypress function and only then render the scene to the texture, instead of doing it every frame (example: Screenshot).
If you call "target.GetTexture()" before you call "GraphicsDevice.ResolveRenderTarget(...)" you will get an error.
If you want to make four different tiles (= 4 different textures) then just repeat the same as above for 3 more and change the coordinates in the "spriteBatch.Draw(...)" function.
Do you want to know what I'm working on? Click
here