-
-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Renderers/SDL3] Add image rendering and scissor support to SDL3 renderer #246
[Renderers/SDL3] Add image rendering and scissor support to SDL3 renderer #246
Conversation
When I first implemented images, the example was split and I just inserted an image to render. Now the SDL3 example uses the video demo and the image example in the SDL2 example also goes unused, I'll leave the loading there as an example but I'm not sure what the ideal change to make it. |
renderers/SDL3/clay_renderer_SDL3.c
Outdated
const SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, config->imageData); | ||
const SDL_FRect dest = { rect.x, rect.y, rect.w, rect.h }; | ||
|
||
SDL_RenderTexture(renderer, texture, NULL, &dest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After it's rendered, the texture should be destroyed here:
SDL_RenderTexture(renderer, texture, NULL, &dest); | |
SDL_RenderTexture(renderer, texture, NULL, &dest); | |
SDL_DestroyTexture(texture); |
Is there a reason why we pass a surface and then convert it into a texture? The SDL_image library allows us to get a texture directly for any image ( |
Thank you for the great work here, we just get the DestroyTexture in to prevent the memory getting leaked, then we can merge it 😁 |
69e0839
to
1848f1f
Compare
Thanks for merging; sorry I didn't get to the additional changes myself! I've been busy with work. |
That's totally fine, thank you for the good work! |
Implements
CLAY_RENDER_COMMAND_TYPE_IMAGE
for the SDL3 renderer using SDL_image essentially identically to how it's done in SDL2 (see #208).Also implements
CLAY_RENDER_COMMAND_TYPE_SCISSOR_START
/CLAY_RENDER_COMMAND_TYPE_SCISSOR_END
based on the similar implementation in the SDL2 renderer.