렌더 타겟이 작동하는 방식을 근본적으로 오해하고 있습니다. RenderTargets는 Spritebatch draw draw가 그리는 텍스처 일뿐입니다.RenderTargets XNA에서 순서 그리기
그래서이 코드를 사용하여 GUI 창을 렌더링하여 클라이언트 영역을 그릴 수 있고 그 밖에 잘릴 수 있는지 확인했습니다.
for (int i = Controls.Count - 1; i >= 0; i--)
{
RenderTarget2D oldTarget;
if (graphics.GetRenderTargets().Count() == 0) oldTarget = null;
else oldTarget = (RenderTarget2D)graphics.GetRenderTargets()[0].RenderTarget; // Get the old target being used.
graphics.SetRenderTarget(canvas); //set the target to a temporary RT
graphics.Clear(Color.Black); // Clear it
Control c = Controls[i]; // Get the current control (a form in this case)
c.Draw(spriteBatch, gameTime); // Draw it to the temp RT
graphics.SetRenderTarget(oldTarget); // Set the RT back to the main RT
Vector2 dest = c.DrawCoOrds(); // Gets the draw coordinates of the control
spriteBatch.Begin();
spriteBatch.Draw(canvas, new Rectangle((int)dest.X, (int)dest.Y, c.Bounds.Width, c.Bounds.Height), new Rectangle((int)dest.X, (int)dest.Y, c.Bounds.Width, c.Bounds.Height), Color.White);
// take the rect from the temp RT and draw it to the main RT.
spriteBatch.End();
}
그러나이 코드는 어떻게 든 주요 RT를 삭제해야하지만 난 이유를 이해 해달라고 의미 목록의 마지막 형태를 그립니다. RT가 임시 캔버스로 설정되었을 때만 명확하게 호출합니다.