Best way to draw a background for a 2D platform game?

Started by simonhyttfors, May 10, 2013, 15:42:20

Previous topic - Next topic

simonhyttfors

I am really new to LWJGL and right now I am trying to make a really simple platform game to try it out. I have created the simple layout and I know how to add new objects like shapes and such. The problem occurs when I try to draw a sky or ground. I just did this by adding new quads with blue or green colors that span either over the entire display or just to make a fairly nice ground. This worked fine on other stronger, stationary computers but to my laptop the whole screen is just flickering. This is probably because my laptop can't handle drawing new quads 60 times/second. So I am wondering if anyone might know a way to stop the background and ground from updating and to just be drawn at load and never again. Is this possible? How would you make a really simple background?
/Simon

quew8

The problem is that you are always going to have other objects moving across the background and if you are not redrawing the background then the image of the object in it's last position will stay there too. Take a read of the first section of this: http://www.glprogramming.com/red/chapter02.html.
You could use the stencil buffer to "remember" where you need to draw over but this is just going to take up more time than redrawing the whole background. I would however, be surprised if your laptop (however old) could not handle redrawing a whole screen quad every frame, and even if this was the case I don't think flickering would be the result. I would suggest updating drivers and if the problem persists post some rendering code / computer specs.