Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Take for an example I have the background scene of a game which should remain static for an interval.Then for every time redrawing the scene,is it better for me to store the color buffer for every pixel on the viewport and redrawing using the stored color buffer or to applying a texture to the whole background or to draw the triangular,quad meshes?

share|improve this question

migrated from stackoverflow.com Jun 23 '12 at 23:49

This question came from our site for professional and enthusiast programmers.

2 Answers 2

In short: If you are developing for a modern machine, you usually can redraw everything that should be on the screen, the only exception being images that are difficult to compute/are computed once every few frames because of perfomance hit.

Detailed: Try rendering the static parts just like the dynamic. Premature optimization is the root of all evil, and you should generally avoid it. Measure the timings, and there's huge chance you won't even need to cache the background at all.

If, however rendering the background is expensive, you should use FBO to store the data. The method of putting it back on the screen depends on the type of game you're writing, however textured quad rendered with basic fragment shader shouldn't be too slow compared to direct pixel-copy. It will also allow you to reduce the size of the background, if you feel that storing whole screen is too much.

share|improve this answer
2  
+1; definitely just redraw the entire scene every frame. It's not going to be a performance problem - honest! - and GPUs are intended to be used this way anyhow, so it will likely be much faster than trying anything clever or tricksy to avoid doing so. –  Darth Satan Jun 24 '12 at 0:22

Assuming you can draw on the buffer effectively and you're using a 'clean' scene (only the stuff you want in the background permanently) to render the initial background, using the buffer should be a faster way of rendering the composite scene. This is especially true if the background isn't a simple image file but rather a separate redering. Even if you are just using a bilboard image in the back of the scene, rendering the polygons and textures to the image buffer is much higher up in the graphics pipeline.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.