Skip to content

Commit c43ff93

Browse files
committed
Fix two WINDOW scaling problems (GitHub Issue #113):
- coordinates should be multiplied by e.g. 'width - 1', not just 'width'. - CINT() macro was not rounding positive values properly
1 parent b240a65 commit c43ff93

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Version 1.06.0
8383
- #858: C backend: fix internal structure size mismatch due to wrong padding when nesting packed structures
8484
- C backend: fix array descriptor mangling to avoid naming conflicts where array data types differ only by const
8585
- #823: Function overload resolution for [const] array() and passing non-const array argument to const array parameter
86+
- Github #113: When a WINDOW was active, the top/right edges (bottom/right for WINDOW SCREEN) were transformed out of the viewport.
8687

8788

8889
Version 1.05.0

src/gfxlib2/gfx_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ void fb_hSetPixelTransfer(FB_GFXCTX *context, unsigned int color)
126126
void fb_hTranslateCoord(FB_GFXCTX *context, float fx, float fy, int *x, int *y)
127127
{
128128
if (context->flags & CTX_WINDOW_ACTIVE) {
129-
fx = ((fx - context->win_x) * context->view_w) / context->win_w;
130-
fy = ((fy - context->win_y) * context->view_h) / context->win_h;
129+
fx = ((fx - context->win_x) * (context->view_w - 1)) / context->win_w;
130+
fy = ((fy - context->win_y) * (context->view_h - 1)) / context->win_h;
131131
}
132132

133133
*x = CINT(fx);

src/rtlib/fb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#define MIN(a,b) ((a) < (b) ? (a) : (b))
8787
#define MAX(a,b) ((a) > (b) ? (a) : (b))
8888
#define MID(a,b,c) MIN(MAX((a), (b)), (c))
89-
#define CINT(x) ((x) > 0.0 ? (int)(x) + 0.5 : (int)(x - 0.5))
89+
#define CINT(x) ((x) > 0.0 ? (int)((x) + 0.5) : (int)((x) - 0.5))
9090

9191
#define SWAP(a,b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
9292

0 commit comments

Comments
 (0)