summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-02 19:34:30 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-02 19:34:30 +0200
commitaa7d9295e56c87802f2bfd3b6b69a56f351aabeb (patch)
tree8d1e0383b3bf2346e1978477c03efd5ff559c796
parent8e7c651faa2e7525cc2e4251516585f89b822ab8 (diff)
VisBuf: Respect the Paint origin
-rw-r--r--src/ui/paint.c7
-rw-r--r--src/ui/paint.h1
-rw-r--r--src/ui/visbuf.c3
3 files changed, 10 insertions, 1 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c
index b92be27e..439bdd37 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -41,6 +41,7 @@ void init_Paint(iPaint *d) {
41 d->dst = get_Window(); 41 d->dst = get_Window();
42 d->setTarget = NULL; 42 d->setTarget = NULL;
43 d->oldTarget = NULL; 43 d->oldTarget = NULL;
44 d->oldOrigin = zero_I2();
44 d->alpha = 255; 45 d->alpha = 255;
45} 46}
46 47
@@ -48,6 +49,8 @@ void beginTarget_Paint(iPaint *d, SDL_Texture *target) {
48 SDL_Renderer *rend = renderer_Paint_(d); 49 SDL_Renderer *rend = renderer_Paint_(d);
49 if (!d->setTarget) { 50 if (!d->setTarget) {
50 d->oldTarget = SDL_GetRenderTarget(rend); 51 d->oldTarget = SDL_GetRenderTarget(rend);
52 d->oldOrigin = origin_Paint;
53 origin_Paint = zero_I2();
51 SDL_SetRenderTarget(rend, target); 54 SDL_SetRenderTarget(rend, target);
52 d->setTarget = target; 55 d->setTarget = target;
53 } 56 }
@@ -59,8 +62,10 @@ void beginTarget_Paint(iPaint *d, SDL_Texture *target) {
59void endTarget_Paint(iPaint *d) { 62void endTarget_Paint(iPaint *d) {
60 if (d->setTarget) { 63 if (d->setTarget) {
61 SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget); 64 SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget);
65 origin_Paint = d->oldOrigin;
66 d->oldOrigin = zero_I2();
62 d->oldTarget = NULL; 67 d->oldTarget = NULL;
63 d->setTarget = NULL; 68 d->setTarget = NULL;
64 } 69 }
65} 70}
66 71
diff --git a/src/ui/paint.h b/src/ui/paint.h
index e894b62f..dfc9260d 100644
--- a/src/ui/paint.h
+++ b/src/ui/paint.h
@@ -33,6 +33,7 @@ struct Impl_Paint {
33 iWindow * dst; 33 iWindow * dst;
34 SDL_Texture *setTarget; 34 SDL_Texture *setTarget;
35 SDL_Texture *oldTarget; 35 SDL_Texture *oldTarget;
36 iInt2 oldOrigin;
36 uint8_t alpha; 37 uint8_t alpha;
37}; 38};
38 39
diff --git a/src/ui/visbuf.c b/src/ui/visbuf.c
index 8f7a4c46..0097b12a 100644
--- a/src/ui/visbuf.c
+++ b/src/ui/visbuf.c
@@ -21,6 +21,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 21SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
22 22
23#include "visbuf.h" 23#include "visbuf.h"
24#include "paint.h"
24#include "window.h" 25#include "window.h"
25#include "util.h" 26#include "util.h"
26 27
@@ -224,6 +225,8 @@ void draw_VisBuf(const iVisBuf *d, const iInt2 topLeft, const iRangei yClipBound
224 continue; /* Outside the clipping area. */ 225 continue; /* Outside the clipping area. */
225#endif 226#endif
226 } 227 }
228 dst.x += origin_Paint.x;
229 dst.y += origin_Paint.y;
227#if defined (DEBUG_SCALE) 230#if defined (DEBUG_SCALE)
228 dst.w *= DEBUG_SCALE; 231 dst.w *= DEBUG_SCALE;
229 dst.h *= DEBUG_SCALE; 232 dst.h *= DEBUG_SCALE;