Gabry,
That’s right, the #define 's are quite dirty. I wanted to simplify the prototypes and
avoid an if()…else() in the implementation. Also using a parameter for the layer number
would lead to dynamic memory allocation I guess. But finally, thinking about it twice,
it would not slow down because the LayeredDisplay object would be allocated once at the
begining of a scene or even at the begining of a whole program, and freed at the end so I guess
you’re right.
An average method to keep the prototypes simple would be to add a method for defining the
blit method:
SDL_SetLayeredDisplayBlitMethod (Uint32 flip_or_dirty);
One drawback is that with the #define solution, I can shrink the size of the data structure
if the Flip method is choosen. Now I have either to store the dirty rectangle list in both cases
or separate in 2 disctinct structures and cast properly, or store the dirty rectangle list info as
global variables. (or maybe another solution)
As for the number of layers, I would add a parameter to:
SDL_CreateRGBLayeredDisplay (… int width, int height, int n_layers, …)
as you suggested, and replace the static array “layers” accordingly.
To finish, my main question, before any comment on the code itself, is,
do you think such a tool is useful, is it worth doing the implementation, or
is it pointless ?
Thank you for your interest !
Julien
----- Message d’origine ----De : Gabriele Greco <gabriele.greco at darts.it>
? : A list for developers using the SDL library. (includes SDL-announce)
Envoy? le : Jeudi, 12 Juin 2008, 15h00mn 06s
Objet : Re: [SDL] Layered display
On Wed, Jun 11, 2008 at 4:32 PM, julien CLEMENT <@Julien_Clement1> wrote:
Hi all,
I’ve quickly written an interface header defining a very basic and generic
system to support multiple layers in SDL, in the form of an SDL_Surface array.
I don’t like the #define method for determine layers number and blit method, why not to use a parameter in the create API for the first and a boolean flag in the display method for the second?
–
Bye,
Gabry
_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr