SDL Surface Array

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

Could you be more specific? Do you mean to put the surfaces in an array?

Best regards
Daniel Liljeberg> ----- Original Message -----

From: bronnum-hansen@mail.dk (Christian Bronnum-Hansen)
To:
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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? :slight_smile:

Marc

Br?nnum-Hansen wrote:> 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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi!

Is it possible to make an array of SDL Surfaces?

I don’t think you can (safely) do that without hacking SDL…

If not, is there an alternative?

An array of pointers to SDL Surfaces;

int		nsurfaces;
SDL_Surface	**surfaces;

or

int		nsurfaces;
SDL_Surface	*surface[MAX_SURFACES];

or something like that.

I’d strongly suggest that approach anyway, and also generally, when it
comes do dealing with “arrays of objects”. I you’re doing C++, it’s
probably an even better idea to stay away from arrays of objects, as
they’re a bit “special” WRT ctors and dtors.

//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.nethttp://www.reologica.se —On Friday 20 February 2004 17.18, Br?nnum-Hansen wrote:

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 PendletonOn Fri, 2004-02-20 at 10:18, Br?nnum-Hansen wrote:

I hope you can help me as this is a rather large problem for me.
Christian


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+

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

M.A. Oude Kotte wrote:> 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? :slight_smile:

Marc

Br?nnum-Hansen wrote:

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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: bronnum-hansen@mail.dk (Christian Bronnum-Hansen)
To:
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

M.A. Oude Kotte wrote:

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? :slight_smile:

Marc

Br?nnum-Hansen wrote:

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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.nethttp://www.reologica.se —On Friday 20 February 2004 18.52, Br?nnum-Hansen 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.

Well, I haven’t seen a vector before…
Could you tell me how to use it?

DAMiEN <damien_ at hotmail.com> wrote:> 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” <@Christian_Bronnum-Ha>
To:
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

M.A. Oude Kotte wrote:

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? :slight_smile:

Marc

Br?nnum-Hansen wrote:

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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.

Well I’m new in both C++ and SDL and haven’t used pointers before.
Could you tell me how they work?> 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.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Bob Pendleton wrote:

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.

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> On Fri, 2004-02-20 at 10:18, Br?nnum-Hansen wrote:

  Bob Pendleton

I hope you can help me as this is a rather large problem
for me.
Christian


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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

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

DAMiEN <damien_ at hotmail.com> wrote:> 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” <@Christian_Bronnum-Ha>
To:
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

of course thats possible (:> ----- Original Message -----

From: bronnum-hansen@mail.dk (Christian Bronnum-Hansen)
To:
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

DAMiEN <damien_ at hotmail.com> wrote:

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”
To:
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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: bronnum-hansen@mail.dk (Christian Bronnum-Hansen)
To:
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

DAMiEN <@Daniel_Liljeberg> wrote:

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”
To:
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Bob Pendleton <@Bob_Pendleton> wrote:

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.

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 PendletonOn Fri, 2004-02-20 at 11:57, Br?nnum-Hansen wrote:

On Fri, 2004-02-20 at 10:18, Br?nnum-Hansen wrote:

Best regards,
Christian

  Bob Pendleton

I hope you can help me as this is a rather large problem
for me.
Christian


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+

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> Well I’m new in both C++ and SDL and haven’t used pointers before.

Could you tell me how they work?

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++ :wink: (I don’t
mean to be rude)

Karl.>From: Br?nnum-Hansen

Reply-To: sdl at libsdl.org
To: sdl at libsdl.org
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?

DAMiEN <damien_ at hotmail.com> wrote:

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”
To:
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

M.A. Oude Kotte wrote:

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? :slight_smile:

Marc

Br?nnum-Hansen wrote:

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
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

No, you’re not dizzing me at all.
Thanks a lot for your help.
The link you gave me looks fine.

DAMiEN <damien_ at hotmail.com> wrote:> 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” <@Christian_Bronnum-Ha>
To:
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

DAMiEN <damien_ at hotmail.com> wrote:

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” <@Christian_Bronnum-Ha>
To:
Sent: Friday, February 20, 2004 5:18 PM
Subject: [SDL] SDL Surface Array

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
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Br?nnum-Hansen wrote:

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