I have a data structure

struct Vector
{
float x, y, z;
};

I have loaded an SDL_Surface with my own Image class the
uses the SDL_image library.

So I have:

Image *hmapImg = new Image();

My Image class has the SDL_Surface* member
Image.theImage.

How would I allocate space for an array of type Vector *
to hold one Vector for every pixel of the loaded image, then
loop through the loaded image picking out the vertices
with Vector.x being the x position in the image, Vector.z
being the y position in the image, and Vector.y being a
value from 0-255 based on the Alpha value of the pixel
at x,y?

To the best of my knowledge this SHOULD just be a few lines
and then a few more inside of 2 nested for loops.

Thanks!
-Randall

simply grab hmapImage->theImage->w and hmapImage->theImage->h, and make an
array of Vectors like so:

Vector* VectorArray = new Vector [ hmapImage->theImage->w *
hmapImage->theImage->h ] ;

or, if you want to get fancy, use STL:

vector < vector < Vector > > vvVector ;>From: Randall Leeds

To: sdl at libsdl.org
Date: Fri, 07 Dec 2001 16:57:56 -0500

I have a data structure

struct Vector
{
float x, y, z;
};

I have loaded an SDL_Surface with my own Image class the
uses the SDL_image library.

So I have:

Image *hmapImg = new Image();

My Image class has the SDL_Surface* member
Image.theImage.

How would I allocate space for an array of type Vector *
to hold one Vector for every pixel of the loaded image, then
loop through the loaded image picking out the vertices
with Vector.x being the x position in the image, Vector.z
being the y position in the image, and Vector.y being a
value from 0-255 based on the Alpha value of the pixel
at x,y?

To the best of my knowledge this SHOULD just be a few lines
and then a few more inside of 2 nested for loops.

Thanks!
-Randall

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