Hi, I’m having a problem when blitting a background to my screen, when i
run gdb it says i get a seg fault in SDL_CalculateBlit(), I think it’s
probably something stupid I’ve done… but I’ve been looking at it for
too long and I can’t figure it out
I’m running on RedHat 9 with SDL 1.2.5
Here’s what i do that i think might be useful
I have a function to make new surfaces for tiling:
SDL_Surface *CreateNewBlankSurface(int width, int height){
Uint32 rmask, gmask, bmask, amask;
SDL_Surface surf;
/ SDL interprets each pixel as a 32-bit number, so our masks must
depend
on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff0000;
gmask = 0x00ff00;
bmask = 0x0000ff;
amask = 0x000000;
#else
rmask = 0x0000ff;
gmask = 0x00ff00;
bmask = 0xff0000;
amask = 0x000000;
#endif
surf = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 0, rmask,
gmask, bmask, amask);
if(surf == NULL) {
cout << "CreateRGBSurface failed: " << SDL_GetError() << endl;
exit(1);
}
return surf;
SDL_FreeSurface(surf);
}
I set the video mode for my screen using:
screen = SDL_SetVideoMode(640, 480, 0, VideoSettings);
if(screen == NULL){
cout << "Failed to set video mode!! " << SDL_GetError() << endl;
exit(1);
}
i make the background surface:
background = CreateNewBlankSurface(screen->w, screen->h);
then i do tiling… then i draw to screen using:
bg.x = 0;
bg.y = 0;
bg.w = background->w;
bg.h = background->h;
SDL_BlitSurface(background, &bg, screen, &bg);
and i get the segfault in there
Please, don’t be to harsh if I’ve done something really stupid