I'm trying to render text (or whatever) off screen. But I have a strange issue where the render target size matches the window size and not the render targets size. Yes, it is a contradiction! Here's the render target:
And here's the code, chopped up and put together to demonstrate what's happening in one place :
UserInterface.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); RenderTarget2D rt = new RenderTarget2D(UserInterface.GraphicsDevice, 200, 200); UserInterface.GraphicsDevice.SetRenderTarget(rt); UserInterface.GraphicsDevice.Clear(Color.Blue); Rectangle rect = new Rectangle(0, 0, 200, 200); UserInterface.SpriteBatch.Draw(pixel, rect, Color.White); renderTarget.GraphicsDevice.SetRenderTarget(null); UserInterface.SpriteBatch.End(); if (frame == 0) rt.SaveAsJpeg(File.OpenWrite("renderTarget.jpg"), rt.Width, rt.Height);
The render target is created at 200x200, I then set the render target on the graphics device. I clear it to blue and draw a pixel at 200x200 (in white). Lastly, I save off the render target.
But why does the sprite batch render the pixel in proportion to the window (just take my word that it is
rectSize / WindowSize * RTSize) rather than filling the render target which I believe it should do in this case?