I'm trying to write a software rasterizer and I'm in the step to texture a triangle.
I'm trying for example to get a pixel from an SDL_Surface which is an image, 100*60, 24bits.
I got a read access violation exception, so I tried to verify the pixels from the surface as:
For instance I try to say
Uint32 *pixels = (Uint32*)texture->pixels;
then
int pixel = pixels[5900];
It gives an access violation. However the calculated pixels count is correct
int pixel_count = (texture->pitch/texture->format->BytesPerPixel)*texture->h;