Quiest
I like turtles!
I`m learning a little SDL atm (working on my first sdl game for the gp2x
) and I`d really like to know what is wrong with this piece of code: (please ignore that it will be slow on the gp2x)
What it should do (in this posted state) is take the surface passed to it by parameter and put it pixel per pixel onto another surface (from "back" to "water") and then return the new surface.
But it doesn't work (and the code worked fine when not put in a function), it just returns the empty surface.
Can someone help me?
Code:
//function to return an altered surface
SDL_Surface *water_effect(SDL_Surface *back)
{
SDL_Surface *water = NULL;
SDL_Rect pixel;
SDL_Rect pixel_mod;
pixel.w=1;
pixel.h=1;
pixel_mod.w=1;
pixel_mod.h=1;
for(int y=1; y<y_res-1; y++)
{
for(int x=1; x<x_res-1; x++)
{
pixel.x=x;
pixel.y=y;
//some code here which has nothing to do with the problem
pixel_mod.x=pixel.x;
pixel_mod.y=pixel.y;
SDL_BlitSurface(back,&pixel_mod,water,&pixel);
}
}
return water;
}
What it should do (in this posted state) is take the surface passed to it by parameter and put it pixel per pixel onto another surface (from "back" to "water") and then return the new surface.
But it doesn't work (and the code worked fine when not put in a function), it just returns the empty surface.