Professional Documents
Culture Documents
How To Not Clear Screen Every Frame in XNA 4 - App Hub Forums
How To Not Clear Screen Every Frame in XNA 4 - App Hub Forums
l. 2011 20:53:11 GMT. A pgina atual pode ter sido alterada nesse meio tempo. Saiba mais Estes termos de pesquisa esto realados: not clear screen every frame Verso somente texto
home getting started membership how it works faq news my dashboard Windows Phone Xbox 360 profile community community resources forums events and promotions games catalog review Xbox games playtest Xbox games education education catalog app development game development library documentation developer resources developer talks academia resources support downloads partner offerings community forums App Hub Forums XNA Game Studio XNA Framework How to not clear screen every frame in XNA 4 My Discussions Active Discussions Not Read
Advanced
Search Forums
RenderTarget2D _lastScreenRenderTarget =
protected override void LoadContent() { // Setup our render target to draw to when w _lastScreenRenderTarget = new RenderTarget2D(Graph .... Load the rest of the content .... } protected override void Draw(GameTime cGameTime) { // Clear the scene GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(msBACKGROUND_COLOR);
// If the Screen should not be Cleared each if (!mbClearScreenEveryFrame) { // Draw to a Render Target so we can hav GraphicsDevice.SetRenderTarget(_lastScre } .... Draw everything here .... if {
(!mbClearScreenEveryFrame)
// Clear the screen and draw our Render GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(msBACKGROUND_COLOR) mcSpriteBatch.Begin(); mcSpriteBatch.Draw(_lastScreenRenderTarg mcSpriteBatch.End(); } }
The mbClearScreenEveryFrame variable is toggled when F5 is pressed (not shown in code above). When I do that, the background changes from Black to Purple, so I know that GraphicsDevice.Clear() isn't being called on my RenderTarget, but that's pretty much the only change. What I am expecting to happen is for any moving objects to leave a trail behind them (since the RenderTarget isn't getting cleared each frame, we just draw overtop of the last frame). The only time I do clear my RenderTarget is when the mbClearScreenEveryFrame variable is toggled. Can anybody see what I am doing wrong and how to fix it? Thanks in advance! - Dan - Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA 7/2/2011 8:53 PM Sigil Re: How to not clear screen every frame in XNA 4 In reply to
Answer Reply Quote are automatically cleared when set on to the device unless you created Rendertargets them with usage PreserveContents. If you need to be able to retain the contents of a (10208) texture when you set it on the device, make sure that option is selected in the Member RenderTarget2D constructor. MVP XNA/DirectX MVP -|- Twitter: @SigilXNA -|- YouTube Videos: SigilXNA -|ModeratorWorking on: Ophidian Wars Posts 3,339 7/3/2011 1:26 AM In reply to deadlydogRe: How to not clear screen every frame in XNA 4 Reply Quote Awesome, I changed my RenderTarget2D constructor to the following and it is working properly now. Thanks :)
(110)
Posts 104 _lastScreenRenderTarget = new RenderTarget2D(mcGraphics.GraphicsDevice, mcGraph false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveCon
- Dan - Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA
7/3/2011 12:01 PM cpyburnRe: How to not clear screen every frame in XNA 4
In reply to
Reply Quote why dont you just thread something in your update instead of messing with the draw? (126) the draw can still draw the same frame if it is not updated, so if you have some method that draws the same scene then another method running in the background and when Posts that threaded method is done, just copy the new information in to the update method 245 Page 1 of 1 (4 posts) Previous Discussion Next Discussion
2011 Microsoft Corporation. All rights reserved. Terms of Use Application Provider Agreement Privacy Statement Code of Conduct Feedback