Discussion:
SDL Surface Array
(too old to reply)
Brønnum-Hansen
2004-02-20 16:18:09 UTC
Permalink
Hi!

Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?

I hope you can help me as this is a rather large problem for me.
Christian
DAMiEN
2004-02-20 16:56:44 UTC
Permalink
Could you be more specific? Do you mean to put the surfaces in an array?

Best regards
Daniel Liljeberg

----- Original Message -----
From: "Brønnum-Hansen" <bronnum-***@mail.dk>
To: <***@libsdl.org>
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem for me.
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Brønnum-Hansen
2004-02-20 17:49:46 UTC
Permalink
Yes exactly. I want to call the surfaces by writing for example:

surface[0]
surface[1]
surface[2]
etc.


I was just wondering, are you Scandinavian?

Best regards,
Christian
Post by DAMiEN
Could you be more specific? Do you mean to put the surfaces
in an array?
Best regards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Alan Wolfe
2004-02-20 18:49:06 UTC
Permalink
of course thats possible (:

----- Original Message -----
From: "Brønnum-Hansen" <bronnum-***@mail.dk>
To: <***@libsdl.org>
Sent: Friday, February 20, 2004 9:49 AM
Subject: Re: [SDL] SDL Surface Array


Yes exactly. I want to call the surfaces by writing for example:

surface[0]
surface[1]
surface[2]
etc.


I was just wondering, are you Scandinavian?

Best regards,
Christian
Post by DAMiEN
Could you be more specific? Do you mean to put the surfaces
in an array?
Best regards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
DAMiEN
2004-02-20 19:01:38 UTC
Permalink
Yes I am Scandinavian. Your problem doesn't seem to be SDL specific, rather
C++ know-how. That means that it's off topic. I don't mean to diss you, just
direct you in the right direction. A good alternative would be to buy a C++
book or doing a search on google for c++ pointer or similar. That would most
likley get you on the right track. Here's a link I found when doing a quick
search: http://www.augustcouncil.com/~tgibson/tutorial/ptr.html

Best regards
Daniel Liljeberg

----- Original Message -----
From: "Brønnum-Hansen" <bronnum-***@mail.dk>
To: <***@libsdl.org>
Sent: Friday, February 20, 2004 6:49 PM
Subject: Re: [SDL] SDL Surface Array


Yes exactly. I want to call the surfaces by writing for example:

surface[0]
surface[1]
surface[2]
etc.


I was just wondering, are you Scandinavian?

Best regards,
Christian
Post by DAMiEN
Could you be more specific? Do you mean to put the surfaces
in an array?
Best regards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Brønnum-Hansen
2004-02-20 20:33:46 UTC
Permalink
No, you're not dizzing me at all.
Thanks a lot for your help.
The link you gave me looks fine.
Post by DAMiEN
Yes I am Scandinavian. Your problem doesn't seem to be SDL
specific, rather
C++ know-how. That means that it's off topic. I don't mean
to diss you, just
direct you in the right direction. A good alternative would
be to buy a C++
book or doing a search on google for c++ pointer or similar.
That would most
likley get you on the right track. Here's a link I found
when doing a quick
http://www.augustcouncil.com/~tgibson/tutorial/ptr.html
Best regards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 6:49 PM
Subject: Re: [SDL] SDL Surface Array
Yes exactly. I want to call the surfaces by writing for
surface[0]
surface[1]
surface[2]
etc.
I was just wondering, are you Scandinavian?
Best regards,
Christian
Post by DAMiEN
Could you be more specific? Do you mean to put the
surfaces
Post by DAMiEN
in an array?
Best regards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large
problem
Post by DAMiEN
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
David Olofson
2004-02-20 17:11:14 UTC
Permalink
This post might be inappropriate. Click to display it.
M.A. Oude Kotte
2004-02-20 17:24:45 UTC
Permalink
Pure out of curiosity:
- why do you want an array of surfaces?
- why, if you really want one, don't you just do SDL_Surface array[8];
or something similar? :)

Marc
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem for me.
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Brønnum-Hansen
2004-02-20 17:52:16 UTC
Permalink
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.

Best regards,
Christian
Post by M.A. Oude Kotte
- why do you want an array of surfaces?
- why, if you really want one, don't you just do SDL_Surface
array[8];
or something similar? :)
Marc
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
DAMiEN
2004-02-20 17:59:08 UTC
Permalink
When I need a array of surfaces I usualy just put SDL_Surface* in an vector
like vector<SDL_Surface*>.
haven't had any problems with that...

Best ragards
Daniel Liljeberg

----- Original Message -----
From: "Brønnum-Hansen" <bronnum-***@mail.dk>
To: <***@libsdl.org>
Sent: Friday, February 20, 2004 6:52 PM
Subject: Re: [SDL] SDL Surface Array


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.

Best regards,
Christian
Post by M.A. Oude Kotte
- why do you want an array of surfaces?
- why, if you really want one, don't you just do SDL_Surface
array[8];
or something similar? :)
Marc
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Brønnum-Hansen
2004-02-20 18:10:55 UTC
Permalink
Well, I haven't seen a vector before...
Could you tell me how to use it?
Post by DAMiEN
When I need a array of surfaces I usualy just put
SDL_Surface* in an vector
like vector<SDL_Surface*>.
haven't had any problems with that...
Best ragards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 6:52 PM
Subject: Re: [SDL] SDL Surface Array
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.
Best regards,
Christian
Post by M.A. Oude Kotte
- why do you want an array of surfaces?
- why, if you really want one, don't you just do
SDL_Surface
Post by M.A. Oude Kotte
array[8];
or something similar? :)
Marc
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large
problem
Post by M.A. Oude Kotte
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Clemens Kirchgatterer
2004-02-20 22:26:14 UTC
Permalink
Post by Brønnum-Hansen
Well, I haven't seen a vector before...
Could you tell me how to use it?
without any offending: this is way offtopic. you really should do your
homework first. there are plenty of c/c++ tutorials out in the wild. ask
google.

clemens
David Olofson
2004-02-20 18:13:05 UTC
Permalink
Post by Brønnum-Hansen
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.


//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 ---
Brønnum-Hansen
2004-02-20 18:24:22 UTC
Permalink
Post by Brønnum-Hansen
Post by Brønnum-Hansen
It is because I want an integer to decide which image is
shown. And
Post by Brønnum-Hansen
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.
Well I'm new in both C++ and SDL and haven't used pointers before.
Could you tell me how they work?
Post by Brønnum-Hansen
//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
http://www.libsdl.org/mailman/listinfo/sdl
Bernhard Bliem
2004-02-20 19:41:59 UTC
Permalink
Hi there

You should try the following:
SDL_Surface *array[x];

Don't forget to free every surface when you quit the program.

By the way, if you don't know anything about pointers, you should first
learn about them before working with SDL... Sorry, but I don't know any
good english tutorials. Probably buy a book.

Regards,
Bernhard
Post by Brønnum-Hansen
Well I'm new in both C++ and SDL and haven't used pointers before.
Could you tell me how they work?
Brønnum-Hansen
2004-02-21 18:18:06 UTC
Permalink
Post by Brønnum-Hansen
Post by Brønnum-Hansen
It is because I want an integer to decide which image is
shown. And
Post by Brønnum-Hansen
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
Post by Brønnum-Hansen
//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
http://www.libsdl.org/mailman/listinfo/sdl
David Olofson
2004-02-21 19:30:13 UTC
Permalink
On Saturday 21 February 2004 19.18, Brønnum-Hansen wrote:
[...]
Post by Brønnum-Hansen
Post by David Olofson
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?
A pointer *has* a type; it's a pointer. Actually, it's also a pointer
to something; in this case a pointer to an SDL_Surface struct - or
"SDL_Surface *", expressed in C/C++.
Post by Brønnum-Hansen
Please, could I get a short example?
//The surfaces
SDL_Surface *surfaces[8];

//Load graphics
surfaces[0] = IMG_Load("picture1.png");
surfaces[1] = IMG_Load("picture2.png");
surfaces[2] = IMG_Load("picture3.png");
...
surfaces[7] = IMG_Load("picture8.png");
//(Add error checking!)

//Do kewl stuff
...

//Free surfaces
for(int i = 0; i < 8; ++i)
SDL_FreeSurface(surfaces[i]);


[...]
Post by Brønnum-Hansen
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.
It *is* off-topic, as it's not specific to SDL in any way whatsoever.
We're talking about very basic C/C++ stuff. If you've read something
that actually explains pointers in a comprehensible way, this stuff
should be quite obvious.

Google comes up with countless hits on books and stuff about C and C++
for beginners, and I guess there are a few on-line resources as well,
though I didn't find one right away. I'd recommend getting one of
those books anyway, though I don't know which ones are best. (The one
I learnt C from was in swedish, and has no translations AFAIK. Not
*that* far form danish, but you have to be pretty much fluent in the
language for this kind of litterature.)


//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 ---
Brønnum-Hansen
2004-02-21 20:04:19 UTC
Permalink
Post by David Olofson
[...]
Post by Brønnum-Hansen
Post by David Olofson
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?
A pointer *has* a type; it's a pointer. Actually, it's also
a pointer
to something; in this case a pointer to an SDL_Surface
struct - or
"SDL_Surface *", expressed in C/C++.
Post by Brønnum-Hansen
Please, could I get a short example?
//The surfaces
SDL_Surface *surfaces[8];
//Load graphics
surfaces[0] = IMG_Load("picture1.png");
surfaces[1] = IMG_Load("picture2.png");
surfaces[2] = IMG_Load("picture3.png");
...
surfaces[7] = IMG_Load("picture8.png");
//(Add error checking!)
//Do kewl stuff
...
//Free surfaces
for(int i = 0; i < 8; ++i)
SDL_FreeSurface(surfaces[i]);
[...]
Post by Brønnum-Hansen
I really hope you don't consider this as off-topic because
I really
Post by Brønnum-Hansen
need this help and don't know where I'm supposed to get
it, if not
Post by Brønnum-Hansen
here.
It *is* off-topic, as it's not specific to SDL in any way
whatsoever.
We're talking about very basic C/C++ stuff. If you've read
something
that actually explains pointers in a comprehensible way,
this stuff
should be quite obvious.
Google comes up with countless hits on books and stuff about
C and C++
for beginners, and I guess there are a few on-line resources
as well,
though I didn't find one right away. I'd recommend getting
one of
those books anyway, though I don't know which ones are best.
(The one
I learnt C from was in swedish, and has no translations
AFAIK. Not
*that* far form danish, but you have to be pretty much
fluent in the
language for this kind of litterature.)
Yes it is. And it was actually what I did before asking here. But I made an error which gave me a lot of errors when compiling which made me think that I had done something wrong. It was just a stupid error.
I apologize...

Thank you for your help.
Post by David Olofson
//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
http://www.libsdl.org/mailman/listinfo/sdl
Kevin
2004-02-21 19:41:10 UTC
Permalink
You can skip the pointer1 stuff and do something like this instead:

SDL_Surface *pSurfaces[MAX_SURFS];

pSurfaces[0] = IMG_Load("picture1.png");
pSurfaces[1] = IMG_Load("picture2.png");
...

That would load picture1.png into the first element of the array, and
picture2.png into the second element of the array, etc.

If you wanted to load a whole bunch of images, then you'd need a for
loop or a while loop. Now, if all of your pictures all start with
"picture" and are all PNGs, you can do something like this:

SDL_Surface *pSurfaces[MAX_SURFS];
Char szImgFile[255];

// this goes in the loading function, or wherever you choose to put it
for (int i = 0; i < MAX_SURFS; ++i)
{
// clear out the file name for the current image
memcpy(szImgFile, '\0', 255); // this fills all 255 characters
in the // file name with the
null-terminating
// character.

// build the file name to the current image
strcpy(szImgFile, "picture");
strcat(szImgFile, atof(i+1)); // concatenate the character
returned by // atof()
strcat(szImgFile, ".png"); // add the .png to the end of
the name

// load the image into the current surface
pSurfaces[i] = IMG_Load(szImgFile);
}

And when it comes time to free the surfaces from memory (ie. When you're
program is shutting down), you can use a for loop again:

for (int i = 0; i < MAX_SURFS; ++i)
{
SDL_FreeSurface(pSurfaces[i]);
}

That's one possible way of doing it.
Hope that helps a bit.

Kevin

-----Original Message-----
From: sdl-***@libsdl.org [mailto:sdl-***@libsdl.org] On Behalf Of
Brønnum-Hansen
Sent: Saturday, February 21, 2004 2:18 PM
To: ***@libsdl.org
Subject: Re: [SDL] SDL Surface Array

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
Post by David Olofson
//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
http://www.libsdl.org/mailman/listinfo/sdl
Clemens Kirchgatterer
2004-02-22 09:31:44 UTC
Permalink
Post by Kevin
memcpy(szImgFile, '\0', 255);
strcpy(szImgFile, "picture");
strcat(szImgFile, atof(i+1));
strcat(szImgFile, ".png");
sprintf(szImgFile, "picture%i.png", i);
Kevin
2004-02-22 14:38:03 UTC
Permalink
That works too. :)

-----Original Message-----
From: sdl-***@libsdl.org [mailto:sdl-***@libsdl.org] On Behalf Of
Clemens Kirchgatterer
Sent: Sunday, February 22, 2004 5:32 AM
To: ***@libsdl.org
Subject: Re: [SDL] SDL Surface Array
Post by Kevin
memcpy(szImgFile, '\0', 255);
strcpy(szImgFile, "picture");
strcat(szImgFile, atof(i+1));
strcat(szImgFile, ".png");
sprintf(szImgFile, "picture%i.png", i);

Bob Pendleton
2004-02-20 16:49:39 UTC
Permalink
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
Of course, you can make an array of any data type you want.

The fact that you ask the question makes me wonder what you believe an
array of surfaces *means"? What problem are you trying to solve?

Bob Pendleton
Post by Brønnum-Hansen
I hope you can help me as this is a rather large problem for me.
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
--
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ email: ***@Pendleton.com +
+ web: www.GameProgrammer.com +
+---------------------------------------+
Brønnum-Hansen
2004-02-20 17:57:33 UTC
Permalink
Post by Bob Pendleton
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
Of course, you can make an array of any data type you want.
How then? I've tried but get errors.
Post by Bob Pendleton
The fact that you ask the question makes me wonder what you
believe an
array of surfaces *means"? What problem are you trying to
solve?
It's beacuse I want an animation of bmp's.
And then I want an integer to decide which picture is to be shown.


Best regards,
Christian
Post by Bob Pendleton
Bob Pendleton
Post by Brønnum-Hansen
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
--
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ web: www.GameProgrammer.com +
+---------------------------------------+
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
Bob Pendleton
2004-02-20 19:25:07 UTC
Permalink
Post by Brønnum-Hansen
Post by Bob Pendleton
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
Of course, you can make an array of any data type you want.
How then? I've tried but get errors.
If you know what you are doing:

SDL_Surface animation[size];

will create an array of SDL_Surface structs.

Because you probably want to use SDL functions to create the structures
you most likely want:

SDL_Surface *animation[size];

And then you need to initialize the pointers.
Post by Brønnum-Hansen
Post by Bob Pendleton
The fact that you ask the question makes me wonder what you
believe an
array of surfaces *means"? What problem are you trying to
solve?
It's beacuse I want an animation of bmp's.
And then I want an integer to decide which picture is to be shown.
A vector of pointers to SDL_Surface is what you want.

Bob Pendleton
Post by Brønnum-Hansen
Best regards,
Christian
Post by Bob Pendleton
Bob Pendleton
Post by Brønnum-Hansen
I hope you can help me as this is a rather large problem
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
--
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ web: www.GameProgrammer.com +
+---------------------------------------+
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
--
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ email: ***@Pendleton.com +
+ web: www.GameProgrammer.com +
+---------------------------------------+
Sam Lantinga
2004-02-20 18:23:56 UTC
Permalink
Post by Brønnum-Hansen
Well, I haven't seen a vector before...
Could you tell me how to use it?
Please take this off the list, it is off-topic.

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment
Karl St-Jacques
2004-02-20 20:18:24 UTC
Permalink
You probably need a good c++ reference actually
Vector are some STL (Standard template library) container

If you want a free book, you can take a look at
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html

Many people find this book interesting.

If you know what's you are looking for, and need more info about the syntax
you can take a look at the standard template library programmer's guide
which can give you a lot of insight.

http://www.sgi.com/tech/stl/

But first, you'll probably need a better understanding of C++ ;) (I don't
mean to be rude)

Karl.
Post by DAMiEN
Subject: Re: [SDL] SDL Surface Array
Date: Fri, 20 Feb 2004 19:10:55 +0100
Well, I haven't seen a vector before...
Could you tell me how to use it?
Post by DAMiEN
When I need a array of surfaces I usualy just put
SDL_Surface* in an vector
like vector<SDL_Surface*>.
haven't had any problems with that...
Best ragards
Daniel Liljeberg
----- Original Message -----
Sent: Friday, February 20, 2004 6:52 PM
Subject: Re: [SDL] SDL Surface Array
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.
Best regards,
Christian
Post by M.A. Oude Kotte
- why do you want an array of surfaces?
- why, if you really want one, don't you just do
SDL_Surface
Post by M.A. Oude Kotte
array[8];
or something similar? :)
Marc
Post by Brønnum-Hansen
Hi!
Is it possible to make an array of SDL Surfaces?
If not, is there an alternative?
I hope you can help me as this is a rather large
problem
Post by M.A. Oude Kotte
for me.
Post by Brønnum-Hansen
Christian
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
Continue reading on narkive:
Loading...