Screen Double buffer implementation | developer.brewmp.com Screen Double buffer implementation | developer.brewmp.com

Developer

Screen Double buffer implementation

Forums:

Does any one has a suggestion of how to implement a double buffer in BREW 1.1 since it doesn't?

I am writing a game where a single sprit should move out of many other. My current implementation is clearing the screen, drawing the background and then all the sprits with the movement.

For rapid movement this is not good enough since it takes too much time for the phone (T720) to draw the BG BMP plus all location calculation for each interval.

Willing to hear all kind of ideas.

Here are my two cents:
1- Use dirty rect approach.... it will make your game faster.
2- draw the objects in turns:
Let's say you must calculate/draw 100 objects.
- Break the draw and calculation routines into 5 groups of 20 objects;
- At each loop you check a to draw the right group;
- If your loop takes 70 ms for each 20 objects, for instance, you will move all 100 objects in about 350 ms. It may sound slow, but the illusion you created is good enough because 20 objects will move each 70 ms making your game look faster...
3- use both (1) and (2) together...

Here are my two cents:
1- Use dirty rect approach.... it will make your game faster.
2- draw the objects in turns:
Let's say you must calculate/draw 100 objects.
- Break the draw and calculation routines into 5 groups of 20 objects;
- At each loop you check a to draw the right group;
- If your loop takes 70 ms for each 20 objects, for instance, you will move all 100 objects in about 350 ms. It may sound slow, but the illusion you created is good enough because 20 objects will move each 70 ms making your game look faster...
3- use both (1) and (2) together...

What is "dirty rect approach" ?

What is "dirty rect approach" ?

The dirty rectangle approach is a commonly used algorithm in computer graphics whereby you only redraw the portions of your display that have changed since the last update. It's name derives from the implementation in that you generally subdivide your draw buffer into rectangular regions and when an action is taken in that region (e.g. a sprite moves) you mark it so that indicates that it needs to be redrawn and all the other static regions do not have to be calculated. I'm sure if you do a google search you'll uncover additional detail and probably some implementations too.

The dirty rectangle approach is a commonly used algorithm in computer graphics whereby you only redraw the portions of your display that have changed since the last update. It's name derives from the implementation in that you generally subdivide your draw buffer into rectangular regions and when an action is taken in that region (e.g. a sprite moves) you mark it so that indicates that it needs to be redrawn and all the other static regions do not have to be calculated. I'm sure if you do a google search you'll uncover additional detail and probably some implementations too.

Thank you both.

Thank you both.

Guy wrote:My current implementation is clearing the screen, drawing the background and then all the sprits with the movement.
Is it really necessary to clear the screen every time ? If your background covers the entire screen you don't even need to clear the screen ;) .

Guy wrote:My current implementation is clearing the screen, drawing the background and then all the sprits with the movement.
Is it really necessary to clear the screen every time ? If your background covers the entire screen you don't even need to clear the screen ;) .

Ravnos- You are right, there is no need to clear the screen every time.
As long as you draw your background that covers the old screen.
Also when you clear the screen rapidly you sometimes get a white screen.
It is better to draw the background on top instead.

Ravnos- You are right, there is no need to clear the screen every time.
As long as you draw your background that covers the old screen.
Also when you clear the screen rapidly you sometimes get a white screen.
It is better to draw the background on top instead.