MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_RenderReadPixels

Function SDL_RenderReadPixels

deps/SDL2/src/render/SDL_render.c:3107–3144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3105}
3106
3107int
3108SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
3109 Uint32 format, void * pixels, int pitch)
3110{
3111 SDL_Rect real_rect;
3112
3113 CHECK_RENDERER_MAGIC(renderer, -1);
3114
3115 if (!renderer->RenderReadPixels) {
3116 return SDL_Unsupported();
3117 }
3118
3119 FlushRenderCommands(renderer); /* we need to render before we read the results. */
3120
3121 if (!format) {
3122 format = SDL_GetWindowPixelFormat(renderer->window);
3123 }
3124
3125 real_rect.x = renderer->viewport.x;
3126 real_rect.y = renderer->viewport.y;
3127 real_rect.w = renderer->viewport.w;
3128 real_rect.h = renderer->viewport.h;
3129 if (rect) {
3130 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
3131 return 0;
3132 }
3133 if (real_rect.y > rect->y) {
3134 pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
3135 }
3136 if (real_rect.x > rect->x) {
3137 int bpp = SDL_BYTESPERPIXEL(format);
3138 pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
3139 }
3140 }
3141
3142 return renderer->RenderReadPixels(renderer, &real_rect,
3143 format, pixels, pitch);
3144}
3145
3146void
3147SDL_RenderPresent(SDL_Renderer * renderer)

Callers 4

save_surface_to_bmpFunction · 0.85
DrawCompositeFunction · 0.85
_compareFunction · 0.85
SDLTest_ScreenShotFunction · 0.85

Calls 3

FlushRenderCommandsFunction · 0.85
SDL_GetWindowPixelFormatFunction · 0.85
SDL_IntersectRectFunction · 0.85

Tested by 4

save_surface_to_bmpFunction · 0.68
DrawCompositeFunction · 0.68
_compareFunction · 0.68
SDLTest_ScreenShotFunction · 0.68