At least I see problem with pointer[offset].
C++ will compute address based on data type which is 4 bytes, not 1.
However this does not yet explain why the poiner math below it fails as well, last time I tried...
// pointer = (SDL_Color *)ParaSurface->pixels + (y * ParaSurface->pitch + x * ParaSurface->format->BytesPerPixel);
// *pointer = color;
Will look into this and adjust formula to not multiply by 4.
OK, fixed it, don't feel completely comfortable, leaving pitch out, but for now it works
:
void SpecialGradientTest( SDL_Surface *ParaSurface )
{
int x, y;
int w, h, p, b;
int offset;
SDL_Color color;
SDL_Color *pointer;
h = ParaSurface->h;
w = ParaSurface->w;
p = ParaSurface->pitch;
b = ParaSurface->format->BytesPerPixel;
pointer = (SDL_Color*)(ParaSurface->pixels);
SDL_LockSurface( ParaSurface );
for (y=0; y<h; y++)
{
for (x=0; x<w; x++)
{
offset = y * w + x;
color.r = x & 255;
color.b = y & 255;
color.g = 0;
pointer[offset] = color;
// pointer = (SDL_Color *)ParaSurface->pixels + (y * ParaSurface->pitch + x * ParaSurface->format->BytesPerPixel);
// *pointer = color;
}
}
SDL_UnlockSurface( ParaSurface );
}