# HG changeset patch # User Sam # Date 1710075731 -25200 # Node ID c72b246d841314081fb979358ec245a61a990fd8 # Parent 0a1e68f32fca2b2d4ce3dfc3b6486ff6e7096397 add: config loader; fix: circle-mesh diff -r 0a1e68f32fca -r c72b246d8413 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 0a1e68f32fca -r c72b246d8413 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 = "",