Mercurial > games > semicongine
changeset 357:2942ec187cbe
allow more openArrays, better debug output, better default exports
author | Sam <sam@basx.dev> |
---|---|
date | Sat, 23 Sep 2023 22:10:33 +0700 |
parents | befa060d782d |
children | 407bb5a965a9 |
files | src/semicongine.nim src/semicongine/core/dynamic_arrays.nim src/semicongine/renderer.nim src/semicongine/scene.nim |
diffstat | 4 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine.nim Thu Sep 21 23:34:38 2023 +0700 +++ b/src/semicongine.nim Sat Sep 23 22:10:33 2023 +0700 @@ -1,3 +1,6 @@ +import std/tables +export tables # necessary to use some features without weird compilation error + import semicongine/core export core
--- a/src/semicongine/core/dynamic_arrays.nim Thu Sep 21 23:34:38 2023 +0700 +++ b/src/semicongine/core/dynamic_arrays.nim Sat Sep 23 22:10:33 2023 +0700 @@ -208,9 +208,9 @@ if len > 0: result.setLen(len) -proc newDataList*[T: GPUType](data: seq[T]): DataList = +proc newDataList*[T: GPUType](data: openArray[T]): DataList = result = newDataList(getDataType[T]()) - result.setValues(data) + result.setValues(@data) proc toGPUValue*[T: GPUType](value: seq[T]): DataList = result = newDataList[T](value.len)
--- a/src/semicongine/renderer.nim Thu Sep 21 23:34:38 2023 +0700 +++ b/src/semicongine/renderer.nim Sat Sep 23 22:10:33 2023 +0700 @@ -114,9 +114,9 @@ if input.name == TRANSFORMATTRIBUTE: # will be populated automatically continue if not (input.name in mesh[].attributes): - return (true, &"Shader input '{input.name}' is not available for mesh '{mesh}'") + return (true, &"Shader input '{input.name}' is not available for mesh") if input.theType != mesh[].attributeType(input.name): - return (true, &"Shader input '{input.name}' expects type {input.theType}, but mesh '{mesh}' has {mesh[].attributeType(input.name)}") + return (true, &"Shader input '{input.name}' expects type {input.theType}, but mesh has {mesh[].attributeType(input.name)}") if not input.perInstance and not mesh[].vertexAttributes.contains(input.name): return (true, &"Shader input '{input.name}' expected to be vertex attribute, but mesh has no such vertex attribute (available are: {mesh[].vertexAttributes})") if input.perInstance and not mesh[].instanceAttributes.contains(input.name): @@ -179,7 +179,6 @@ for texture in getValues[Texture](value)[]: scenedata.textures[name].add renderer.device.uploadTexture(texture) - # find all meshes, populate missing attribute values for shader for mesh in scene.meshes.mitems: for inputAttr in inputs:
--- a/src/semicongine/scene.nim Thu Sep 21 23:34:38 2023 +0700 +++ b/src/semicongine/scene.nim Sat Sep 23 22:10:33 2023 +0700 @@ -28,7 +28,7 @@ setValues(scene.shaderGlobals[name], @[data]) scene.dirtyShaderGlobals.add name -proc addShaderGlobalArray*[T](scene: var Scene, name: string, data: seq[T]) = +proc addShaderGlobalArray*[T](scene: var Scene, name: string, data: openArray[T]) = scene.shaderGlobals[name] = newDataList(data) scene.dirtyShaderGlobals.add name