Use clipping functions provided by SDL (#1426)
This commit is contained in:
+4
-2
@@ -61,12 +61,14 @@ static RenRect scaled_rect(const RenRect rect, const int scale) {
|
||||
|
||||
void renwin_clip_to_surface(RenWindow *ren) {
|
||||
SDL_Surface *surface = renwin_get_surface(ren);
|
||||
ren->clip = (RenRect) {0, 0, surface->w, surface->h};
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
}
|
||||
|
||||
|
||||
void renwin_set_clip_rect(RenWindow *ren, RenRect rect) {
|
||||
ren->clip = scaled_rect(rect, renwin_surface_scale(ren));
|
||||
SDL_Surface *surface = renwin_get_surface(ren);
|
||||
RenRect sr = scaled_rect(rect, renwin_surface_scale(ren));
|
||||
SDL_SetClipRect(surface, &(SDL_Rect){.x = sr.x, .y = sr.y, .w = sr.width, .h = sr.height});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user