# HG changeset patch # User Sam # Date 1694442658 -25200 # Node ID de1e4d0ee5270ef7c9d426860a836d2daa7295fa # Parent 086bafa7f0d7d36aba9710b766c5e717cfcfa078 fix: error with textures as shader-globales diff -r 086bafa7f0d7 -r de1e4d0ee527 src/semicongine/core/gpu_data.nim --- 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]()) diff -r 086bafa7f0d7 -r de1e4d0ee527 src/semicongine/scene.nim --- 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 =