I’ve been working with SDL for a few days now creating a crude widget set.
Everything’s been fine up until I realized that my widgets weren’t being
clipped correctly when they were drawing themselves to the screen (each widget
has its own clipping rectangle information). I couldn’t find any problem in my
container widget code (which actually sets the clipping rectangles in each
child widget) so I decided to see what gdb had to say…
The actual SDL_BlitSurface call was being made with the arguments
(widgetSurface, NULL, SDL_GetVideoSurface(), &clippingRect) and I confirmed
with gdb that widgetSurface->w was in fact greater than clippingRect.w. I
doubted that there were any bugs in SDL_BlitSurface(), so I created a second
clipping rectangle (relative to the widget surface instead of relative to the
screen) and passed it as the second argument to SDL_BlitSurface() and
everything was fine.
I have no problem with creating two separate clipping rectangles, but it seems
a little redundant to me. Am I doing something wrong here or not looking at
this from the correct angle? Here’s basically what I’m having to do now (with
absolute values inserted instead of variables)…
SDL_Rect rect1 = {0, 0, 50, 100};
SDL_Rect rect2 = {300, 200, 50, 100};
SDL_BlitSurface(surface, &rect1, SDL_GetVideoSurface(), &rect2);
SDL_UpdateRects(SDL_GetVideoSurface(), 1, &rect2);
what I’d rather do, but for some reason won’t work…
SDL_Rect rect = {300, 200, 50, 100};
SDL_BlitSurface(surface, NULL, SDL_GetVideoSurface(), &rect);
SDL_UpdateRects(SDL_GetVideoSurface(), 1, &rect);
Any help/explanation you can provide would be greatly appreciated. Sorry if
the formatting on this post sucks, but I’m not too familiar with slrn or vi.
-Chris