# HG changeset patch # User Sam # Date 1710075731 -25200 # Node ID 05dd71c246a36aefd9d055eb30ba938dc26313f5 # Parent 3f220c2b4076fcd6c250d0532d89ab75bf405058 add: config loader; fix: circle-mesh diff -r 3f220c2b4076 -r 05dd71c246a3 semicongine/mesh.nim --- a/semicongine/mesh.nim Sat Mar 09 23:06:27 2024 +0700 +++ b/semicongine/mesh.nim Sun Mar 10 20:02:11 2024 +0700 @@ -492,17 +492,17 @@ inc instanceCounter let - half_w = width / 2 - half_h = height / 2 + rX = width / 2 + rY = height / 2 c = toRGBA(color) step = (2'f32 * PI) / float32(nSegments) var - pos = @[newVec3f(0, 0), newVec3f(0, half_h)] + pos = @[newVec3f(0, 0), newVec3f(rX, 0)] col = @[c, c] - for i in 0 .. nSegments: - pos.add newVec3f(cos(float32(i) * step) * half_w, sin(float32(i) * step) * half_h) + for i in 1 .. nSegments: + pos.add newVec3f(cos(float32(i) * step) * rX, sin(float32(i) * step) * rY) col.add c - result[].smallIndices.add [uint16(0), uint16(i + 1), uint16(i + 2)] + result[].smallIndices.add [uint16(0), uint16(i), uint16(i + 1)] result[].initVertexAttribute(DEFAULT_POSITION_ATTRIBUTE, pos) result[].initVertexAttribute("color", col) diff -r 3f220c2b4076 -r 05dd71c246a3 semicongine/resources.nim --- a/semicongine/resources.nim Sat Mar 09 23:06:27 2024 +0700 +++ b/semicongine/resources.nim Sun Mar 10 20:02:11 2024 +0700 @@ -1,6 +1,7 @@ +import std/parsecfg import std/streams +import std/algorithm import std/json -import std/algorithm import std/strutils import std/sequtils import std/strformat @@ -183,6 +184,9 @@ proc loadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode = path.loadResource_intern(package = package).readAll().parseJson() +proc loadConfig*(path: string, package = DEFAULT_PACKAGE): Config = + path.loadResource_intern(package = package).loadConfig(filename = path) + proc loadFont*( path: string, name = "",