David Olofson wrote:
It is because I want an integer to decide which image is
shown. And
I can’t really find any other way to do this. I’ve tried
SDL_Surface array[8]; but I get a lot of errors.There are many ways of doing that actually, but the simplest
one is
indeed to use arrays. However, since SDL_Surface structs are
created
(ie malloc()ed and filled in) by SDL, you shouldn’t use
arrays of
them. That would require copying structs around, and you’d
have to
free() the SDL_Surface struct you get from SDL. Even though
that part
might actually work, it may well screw up SDL’s internals.
Not sure
about that, but generally, you should never second-guess
libraries
that want to manage their own objects…So, use arrays of pointers to SDL_Surfaces instead.
Okay, I’ve read about pointers and understand them.
But I still don’t understand how I should use them here.
Because, the pointers needs a type, don’t they?
Please, could I get a short example?
Do you mean that I should have an array like this:
SDL_Surface *surface1;
surface1 = IMG_Load(“picture1.png”);
?type? *pointer1;
pointer1 = &surface1;
array[0] = *pointer1;
I really hope you don’t consider this as off-topic because I really need this help and don’t know where I’m supposed to get it, if not here.
Christian> On Friday 20 February 2004 18.52, Br?nnum-Hansen wrote:
//David Olofson - Programmer, Composer, Open Source
Advocate.- Audiality
-----------------------------------------------.
| Free/Open Source audio engine for games and multimedia.
|
| MIDI, modular synthesis, real time effects, scripting,…
|
`-----------------------------------> http://audiality.org
-’
— http://olofson.net — http://www.reologica.se —
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl