Mercurial > games > semicongine
changeset 343:c9b34b41a5a2
fix: error with textures as shader-globales
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 11 Sep 2023 21:30:58 +0700 |
parents | 8c67f67b62fb |
children | b83b3a1ccb05 |
files | src/semicongine/core/gpu_data.nim src/semicongine/scene.nim |
diffstat | 2 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine/core/gpu_data.nim Mon Sep 11 18:23:15 2023 +0700 +++ b/src/semicongine/core/gpu_data.nim Mon Sep 11 21:30:58 2023 +0700 @@ -408,7 +408,7 @@ else: {.error: "Virtual datatype has no value" .} proc setValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) = - value.len = data.len + value.initData(data.len) when T is float32: value.float32[] = data elif T is float64: value.float64[] = data elif T is int8: value.int8[] = data @@ -505,7 +505,7 @@ of Mat43F64: result.mat43f64 = new seq[TMat43[float64]] of Mat4F32: result.mat4f32 = new seq[TMat4[float32]] of Mat4F64: result.mat4f64 = new seq[TMat4[float64]] - of Sampler2D: discard + of Sampler2D: result.texture = new seq[Texture] proc newDataList*[T: GPUType](len=0): DataList = result = newDataList(getDataType[T]()) @@ -514,7 +514,7 @@ proc newDataList*[T: GPUType](data: seq[T]): DataList = result = newDataList(getDataType[T]()) - setValues[T](result, data) + result.setValues(data) proc toGPUValue*[T: GPUType](value: T): DataValue = result = DataValue(theType: getDataType[T]())
--- a/src/semicongine/scene.nim Mon Sep 11 18:23:15 2023 +0700 +++ b/src/semicongine/scene.nim Mon Sep 11 21:30:58 2023 +0700 @@ -29,8 +29,7 @@ scene.dirtyShaderGlobals.add name proc addShaderGlobalArray*[T](scene: var Scene, name: string, data: seq[T]) = - scene.shaderGlobals[name] = newDataList(thetype=getDataType[T]()) - setValues(scene.shaderGlobals[name], data) + scene.shaderGlobals[name] = newDataList(data) scene.dirtyShaderGlobals.add name func getShaderGlobal*[T](scene: Scene, name: string): T =