렌더링 할당 : 다음 코드는 예상대로 완벽하게 렌더링 :XNA 4.0 - 이상한 행동 대상에게 나는 현재 다음과 같은 이상한 문제에 직면하고있다
private void DoRenderSkybox (GameTime Time) {
this.Device.SetRenderTarget(this.GridTexture);
this.Device.SetRenderTarget(null);
// compute a temporary transformation matrix containing
// the combined world and projection transfromation
Matrix WorldViewProjection = this.Camera.View * this.Camera.Projection;
// set the render target to the back buffer in any case
this.Device.SetRenderTarget(null);
// assign the vertex - declaration and the vertex- and the index - buffer
this.Device.SetVertexBuffer(this.SkyboxVertices);
this.Device.Indices = this.SkyboxIndices;
// choose the appropriate technique for the current render pass
this.SceneEffect.CurrentTechnique = SceneEffect.Techniques["Skybox"];
this.SceneEffect.CurrentTechnique.Passes[0].Apply();
this.SceneEffect.Parameters["WorldViewProjection"].SetValue(WorldViewProjection);
// finally render the sykbox with disabled depth stencil buffering
this.Device.DepthStencilState = DepthStencilState.None;
this.Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 36, 0, 12);
this.Device.DepthStencilState = DepthStencilState.Default;
//this.Device.SetRenderTarget(this.GridTexture);
//this.Device.SetRenderTarget(null);
}
을 그러나, 나는 (바로 할당 취소)을 할당하는 경우 과 같이 함수의 끝에서 대상을 렌더링 :
private void DoRenderSkybox (GameTime Time) {
//this.Device.SetRenderTarget(this.GridTexture);
//this.Device.SetRenderTarget(null);
// compute a temporary transformation matrix containing
// the combined world and projection transfromation
Matrix WorldViewProjection = this.Camera.View * this.Camera.Projection;
// set the render target to the back buffer in any case
this.Device.SetRenderTarget(null);
// assign the vertex - declaration and the vertex- and the index - buffer
this.Device.SetVertexBuffer(this.SkyboxVertices);
this.Device.Indices = this.SkyboxIndices;
// choose the appropriate technique for the current render pass
this.SceneEffect.CurrentTechnique = SceneEffect.Techniques["Skybox"];
this.SceneEffect.CurrentTechnique.Passes[0].Apply();
this.SceneEffect.Parameters["WorldViewProjection"].SetValue(WorldViewProjection);
// finally render the sykbox with disabled depth stencil buffering
this.Device.DepthStencilState = DepthStencilState.None;
this.Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 36, 0, 12);
this.Device.DepthStencilState = DepthStencilState.Default;
this.Device.SetRenderTarget(this.GridTexture);
this.Device.SetRenderTarget(null);
}
아무것도 렌더링되지되고있다 - 나는 보라색 화면을 가지고! 그게 당신에게 의미가 있습니까!
P. 샘플이별로 의미가 없다는 것을 알고 있습니다 (렌더 타겟을 할당하고 바로 할당 해제하는 것과 같습니다). 여기서의 실제 시나리오는 훨씬 더 복잡하지만,이 아주 이상한 동작에 대한 문제의 본질을 좁힐 수있었습니다.이 간단한 예제에서 설명 할 수 있습니다!