Skip to content

Commit

Permalink
fix: weird incompatibility problem with nim 2.2.0 and 2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
levovix0 committed Oct 26, 2024
1 parent 0fb1754 commit ed5d88c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/sigui/render/contexts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ proc drawText*(ctx: DrawContext, pos: Vec2, arrangement: Arrangement, color: Vec
placement: Uniform[Vec2],
placementWh: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
uv = placement + ipos * placementWh
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)
uv = placement.Vec2 + ipos * placementWh.Vec2

proc frag(
glCol: var Vec4,
Expand All @@ -328,7 +328,7 @@ proc drawText*(ctx: DrawContext, pos: Vec2, arrangement: Arrangement, color: Vec
color: Uniform[Vec4],
) =
let col = gltex.texture(uv)
glCol = vec4(color.rgb * color.a, color.a) * col.r
glCol = vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a) * col.r

use shader.shader
glEnable(GlBlend)
Expand Down
28 changes: 14 additions & 14 deletions src/sigui/uibase.nim
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ proc drawRect*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius: float
size: Uniform[Vec2],
px: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)

proc frag(
glCol: var Vec4,
Expand All @@ -819,7 +819,7 @@ proc drawRect*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius: float
size: Uniform[Vec2],
color: Uniform[Vec4],
) =
glCol = vec4(color.rgb * color.a, color.a) * roundRect(pos, size, radius)
glCol = vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a) * roundRect(pos, size.Vec2, radius.float)

if blend:
glEnable(GlBlend)
Expand Down Expand Up @@ -894,7 +894,7 @@ proc drawRectStroke*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius:
size: Uniform[Vec2],
px: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)

proc frag(
glCol: var Vec4,
Expand All @@ -907,14 +907,14 @@ proc drawRectStroke*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius:
tileSecondSize: Uniform[Vec2],
secondColor: Uniform[Vec4],
) =
if strokeTiling(pos, size, tileSize, tileSecondSize, radius, borderWidth) > 0:
if strokeTiling(pos, size.Vec2, tileSize.Vec2, tileSecondSize.Vec2, radius, borderWidth) > 0:
glCol =
vec4(secondColor.rgb * secondColor.a, secondColor.a) *
roundRectStroke(pos, size, radius, borderWidth)
vec4(secondColor.Vec4.rgb * secondColor.Vec4.a, secondColor.Vec4.a) *
roundRectStroke(pos, size.Vec2, radius.float, borderWidth.float)
else:
glCol =
vec4(color.rgb * color.a, color.a) *
roundRectStroke(pos, size, radius, borderWidth)
vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a) *
roundRectStroke(pos, size.Vec2, radius.float, borderWidth.float)

if blend:
glEnable(GlBlend)
Expand Down Expand Up @@ -947,7 +947,7 @@ proc drawImage*(ctx: DrawContext, pos: Vec2, size: Vec2, tex: GlUint, color: Vec
size: Uniform[Vec2],
px: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)
uv = ipos

proc frag(
Expand All @@ -959,7 +959,7 @@ proc drawImage*(ctx: DrawContext, pos: Vec2, size: Vec2, tex: GlUint, color: Vec
color: Uniform[Vec4],
) =
let c = gltex.texture(uv)
glCol = vec4(c.rgb, c.a) * roundRect(pos, size, radius) * vec4(color.rgb * color.a, color.a)
glCol = vec4(c.rgb, c.a) * roundRect(pos, size.Vec2, radius.float) * vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a)

if blend:
glEnable(GlBlend)
Expand Down Expand Up @@ -987,7 +987,7 @@ proc drawIcon*(ctx: DrawContext, pos: Vec2, size: Vec2, tex: GlUint, col: Vec4,
size: Uniform[Vec2],
px: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)
uv = ipos

proc frag(
Expand All @@ -999,7 +999,7 @@ proc drawIcon*(ctx: DrawContext, pos: Vec2, size: Vec2, tex: GlUint, col: Vec4,
color: Uniform[Vec4],
) =
let col = gltex.texture(uv)
glCol = vec4(color.rgb * color.a, color.a) * col.a * roundRect(pos, size, radius)
glCol = vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a) * col.a * roundRect(pos, size.Vec2, radius.float)

if blend:
glEnable(GlBlend)
Expand Down Expand Up @@ -1059,7 +1059,7 @@ proc drawShadowRect*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius:
size: Uniform[Vec2],
px: Uniform[Vec2],
) =
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)

proc frag(
glCol: var Vec4,
Expand All @@ -1069,7 +1069,7 @@ proc drawShadowRect*(ctx: DrawContext, pos: Vec2, size: Vec2, col: Vec4, radius:
size: Uniform[Vec2],
color: Uniform[Vec4],
) =
glCol = vec4(color.rgb * color.a, color.a) * distanceRoundRect(pos, size, radius, blurRadius)
glCol = vec4(color.Vec4.rgb * color.Vec4.a, color.Vec4.a) * distanceRoundRect(pos, size.Vec2, radius.float, blurRadius.float)

if blend:
glEnable(GlBlend)
Expand Down
2 changes: 1 addition & 1 deletion tests/t_shaders.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ method draw*(this: ChessTiles, ctx: DrawContext) =
# default sigui specific transformation to correct locate component on screen
# and convert opengl's coordinate system (-1..1) to sigui's coordinate system (0..windowSize_inPixels)
# out `pos` is component-local (0..componentSize_inPixels)
transformation(gl_Position, pos, size, px, ipos, transform)
transformation(gl_Position, pos, size.Vec2, px.Vec2, ipos, transform.Mat4)
# don't use it if you don't need it (and don't call `ctx.passTransform` if so)

proc frag(
Expand Down

0 comments on commit ed5d88c

Please sign in to comment.