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, 14 insertions, 4 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c
index 0166e398..d0a4a579 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -36,18 +36,28 @@ static void setColor_Paint_(const iPaint *d, int color) {
36 36
37void init_Paint(iPaint *d) { 37void init_Paint(iPaint *d) {
38 d->dst = get_Window(); 38 d->dst = get_Window();
39 d->setTarget = NULL;
39 d->oldTarget = NULL; 40 d->oldTarget = NULL;
40} 41}
41 42
42void beginTarget_Paint(iPaint *d, SDL_Texture *target) { 43void beginTarget_Paint(iPaint *d, SDL_Texture *target) {
43 SDL_Renderer *rend = renderer_Paint_(d); 44 SDL_Renderer *rend = renderer_Paint_(d);
44 d->oldTarget = SDL_GetRenderTarget(rend); 45 if (!d->setTarget) {
45 SDL_SetRenderTarget(rend, target); 46 d->oldTarget = SDL_GetRenderTarget(rend);
47 SDL_SetRenderTarget(rend, target);
48 d->setTarget = target;
49 }
50 else {
51 iAssert(d->setTarget == target);
52 }
46} 53}
47 54
48void endTarget_Paint(iPaint *d) { 55void endTarget_Paint(iPaint *d) {
49 SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget); 56 if (d->setTarget) {
50 d->oldTarget = NULL; 57 SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget);
58 d->oldTarget = NULL;
59 d->setTarget = NULL;
60 }
51} 61}
52 62
53void setClip_Paint(iPaint *d, iRect rect) { 63void setClip_Paint(iPaint *d, iRect rect) {