Hi, my code is segfaulting when I do a SDL_FillRect:
widget->surface = SDL_CreateRGBSurface( SDL_SWSURFACE, widget->rect.w,
widget->rect.h, 24, rmask, gmask, bmask, amask );
if( !(widget->surface) ) {
printf( “SDL_CreateRGBSurface() returned NULL (from %s): %s\n”,
widget->name, SDL_GetError() );
return;
}
SDL_Rect bar;
bar.x = 2; bar.y = (widget->rect.h/2)-2;
bar.w = widget->rect.w-4; bar.h = 2;
SDL_FillRect( widget->surface, (const SDL_Rect *)&bar, SDL_MapRGB(
widget->surface->format, 150, 150, 150 ) );
bar.x = 2; bar.y = (widget->rect.h/2);
bar.w = widget->rect.w-4; bar.h = 2;
SDL_FillRect( widget->surface, (const SDL_Rect *)&bar, SDL_MapRGB(
widget->surface->format, 100, 100, 100 ) );
bar.x = ( ( slider->value - slider->min ) / ( slider->max - slider->min
) ) * ( widget->rect.w - 4 ); bar.y = 0;
bar.w = 4; bar.h = widget->rect.h;
SDL_FillRect( widget->surface, (const SDL_Rect *)&bar, SDL_MapRGB(
widget->surface->format, 170, 170, 170 ) );
SDL_DrawRect( widget->surface, (const SDL_Rect *)&bar, SDL_MapRGB(
widget->surface->format, 255, 255, 255 ) );
gdb points to this code: SDL_fillrect.c:292
Did I do something wrong with my code, or is this an issue with SDL?
Thanks,
-Alex