diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-12 23:14:58 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-12 23:14:58 +0300 |
commit | 8824963c806ce80ed919feeb8cae41dbf3116e50 (patch) | |
tree | 5eaf45521d99e8eeac323d95af89d7270af5bf6c /src/ui/paint.c | |
parent | 2b231bb52d7daea0e8921c7bbd7bdd932fd7912c (diff) |
Paint: Keeping track of the set render target
Diffstat (limited to 'src/ui/paint.c')
-rw-r--r-- | src/ui/paint.c | 18 |
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 | ||
37 | void init_Paint(iPaint *d) { | 37 | void 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 | ||
42 | void beginTarget_Paint(iPaint *d, SDL_Texture *target) { | 43 | void 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 | ||
48 | void endTarget_Paint(iPaint *d) { | 55 | void 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 | ||
53 | void setClip_Paint(iPaint *d, iRect rect) { | 63 | void setClip_Paint(iPaint *d, iRect rect) { |