I'm trying to write a software rasterizer and I'm in the step to texture a triangle. I'm trying to get a pixel from an
SDL_Surface which is an image, 100x60 at 24 bits of color depth.
I got a read access violation exception. For instance I try to say
Uint32 * pixels = (Uint32 *)texture->pixels;
int pixel = pixels;
It gives an access violation. However the calculated pixels count is correct
int pixel_count = (texture->pitch / texture->format->BytesPerPixel) * texture->h;
Is this wrong? How can I access the pixels of this surface?