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

Function SDL_RenderCopyF

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

Source from the content-addressed store, hash-verified

2942}
2943
2944int
2945SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
2946 const SDL_Rect * srcrect, const SDL_FRect * dstrect)
2947{
2948 SDL_Rect real_srcrect;
2949 SDL_FRect real_dstrect;
2950 SDL_Rect r;
2951 int retval;
2952
2953 CHECK_RENDERER_MAGIC(renderer, -1);
2954 CHECK_TEXTURE_MAGIC(texture, -1);
2955
2956 if (renderer != texture->renderer) {
2957 return SDL_SetError("Texture was not created with this renderer");
2958 }
2959
2960 /* Don't draw while we're hidden */
2961 if (renderer->hidden) {
2962 return 0;
2963 }
2964
2965 real_srcrect.x = 0;
2966 real_srcrect.y = 0;
2967 real_srcrect.w = texture->w;
2968 real_srcrect.h = texture->h;
2969 if (srcrect) {
2970 if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
2971 return 0;
2972 }
2973 }
2974
2975 SDL_zero(r);
2976 SDL_RenderGetViewport(renderer, &r);
2977 real_dstrect.x = 0.0f;
2978 real_dstrect.y = 0.0f;
2979 real_dstrect.w = (float) r.w;
2980 real_dstrect.h = (float) r.h;
2981 if (dstrect) {
2982 if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
2983 return 0;
2984 }
2985 real_dstrect = *dstrect;
2986 }
2987
2988 if (texture->native) {
2989 texture = texture->native;
2990 }
2991
2992 real_dstrect.x *= renderer->scale.x;
2993 real_dstrect.y *= renderer->scale.y;
2994 real_dstrect.w *= renderer->scale.x;
2995 real_dstrect.h *= renderer->scale.y;
2996
2997 texture->last_command_generation = renderer->render_command_generation;
2998
2999 retval = QueueCmdCopy(renderer, texture, &real_srcrect, &real_dstrect);
3000 return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
3001}

Callers 2

SDL_RenderCopyFunction · 0.85
SDL_RenderCopyExFFunction · 0.85

Calls 6

SDL_SetErrorFunction · 0.85
SDL_IntersectRectFunction · 0.85
SDL_RenderGetViewportFunction · 0.85
SDL_HasIntersectionFFunction · 0.85
QueueCmdCopyFunction · 0.85

Tested by

no test coverage detected