summaryrefslogtreecommitdiff
path: root/src/ui/paint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/paint.c')
-rw-r--r--src/ui/paint.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c
index 85e75f15..a55670e9 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -1,5 +1,7 @@
1#include "paint.h" 1#include "paint.h"
2 2
3#include <SDL_version.h>
4
3iLocalDef SDL_Renderer *renderer_Paint_(const iPaint *d) { 5iLocalDef SDL_Renderer *renderer_Paint_(const iPaint *d) {
4 iAssert(d->dst); 6 iAssert(d->dst);
5 return d->dst->render; 7 return d->dst->render;
@@ -12,6 +14,18 @@ static void setColor_Paint_(const iPaint *d, int color) {
12 14
13void init_Paint(iPaint *d) { 15void init_Paint(iPaint *d) {
14 d->dst = get_Window(); 16 d->dst = get_Window();
17 d->oldTarget = NULL;
18}
19
20void beginTarget_Paint(iPaint *d, SDL_Texture *target) {
21 SDL_Renderer *rend = renderer_Paint_(d);
22 d->oldTarget = SDL_GetRenderTarget(rend);
23 SDL_SetRenderTarget(rend, target);
24}
25
26void endTarget_Paint(iPaint *d) {
27 SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget);
28 d->oldTarget = NULL;
15} 29}
16 30
17void setClip_Paint(iPaint *d, iRect rect) { 31void setClip_Paint(iPaint *d, iRect rect) {
@@ -19,8 +33,12 @@ void setClip_Paint(iPaint *d, iRect rect) {
19} 33}
20 34
21void unsetClip_Paint(iPaint *d) { 35void unsetClip_Paint(iPaint *d) {
36#if SDL_VERSION_ATLEAST(2, 0, 12)
37 SDL_RenderSetClipRect(renderer_Paint_(d), NULL);
38#else
22 const SDL_Rect winRect = { 0, 0, d->dst->root->rect.size.x, d->dst->root->rect.size.y }; 39 const SDL_Rect winRect = { 0, 0, d->dst->root->rect.size.x, d->dst->root->rect.size.y };
23 SDL_RenderSetClipRect(renderer_Paint_(d), &winRect); 40 SDL_RenderSetClipRect(renderer_Paint_(d), &winRect);
41#endif
24} 42}
25 43
26void drawRect_Paint(const iPaint *d, iRect rect, int color) { 44void drawRect_Paint(const iPaint *d, iRect rect, int color) {