src/render/SDL_render.c
changeset 5464 bec064e902cf
parent 5423 b69fa50e80d7
child 5528 15c9c03a80cc
equal deleted inserted replaced
5463:9cdb6f1d791a 5464:bec064e902cf
  1074 
  1074 
  1075     if (!format) {
  1075     if (!format) {
  1076         format = SDL_GetWindowPixelFormat(window);
  1076         format = SDL_GetWindowPixelFormat(window);
  1077     }
  1077     }
  1078 
  1078 
  1079     real_rect.x = 0;
  1079     real_rect.x = renderer->viewport.x;
  1080     real_rect.y = 0;
  1080     real_rect.y = renderer->viewport.y;
  1081     real_rect.w = renderer->viewport.w;
  1081     real_rect.w = renderer->viewport.w;
  1082     real_rect.h = renderer->viewport.h;
  1082     real_rect.h = renderer->viewport.h;
  1083     if (rect) {
  1083     if (rect) {
  1084         if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  1084         if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  1085             return 0;
  1085             return 0;
  1086         }
  1086         }
  1087         if (real_rect.y > rect->y) {
  1087         if (real_rect.y > rect->y) {
  1088             pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
  1088             pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
  1089         }
  1089         }
  1090         if (real_rect.x > rect->x) {
  1090         if (real_rect.x > rect->x) {
  1091             int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
  1091             int bpp = SDL_BYTESPERPIXEL(format);
  1092             pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
  1092             pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
  1093         }
  1093         }
  1094     }
  1094     }
  1095 
  1095 
  1096     return renderer->RenderReadPixels(renderer, &real_rect,
  1096     return renderer->RenderReadPixels(renderer, &real_rect,