# HG changeset patch # User sam # Date 1717509082 -25200 # Node ID a4aa9f374d44a2566ee8c82eb5fcc0aa08356eac # Parent 71315636ba821f09d5a02752820ffc4571093013 did: more renaming diff -r 71315636ba82 -r a4aa9f374d44 semicongine/algorithms.nim --- a/semicongine/algorithms.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/algorithms.nim Tue Jun 04 20:51:22 2024 +0700 @@ -71,7 +71,7 @@ for j in i + 1 ..< assignedAreas.len: assert not assignedAreas[i].advanceIfOverlap(assignedAreas[j])[0], &"{assignedAreas[i]} and {assignedAreas[j]} overlap!" - result.atlas = newImage[T](maxDim, maxDim) + result.atlas = NewImage[T](maxDim, maxDim) result.coords.setLen(images.len) for rect in assignedAreas: for y in 0 ..< rect.h: diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/audiotypes.nim --- a/semicongine/core/audiotypes.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/audiotypes.nim Tue Jun 04 20:51:22 2024 +0700 @@ -18,7 +18,7 @@ sin(x * 2 * Pi * f) result = ret -proc sineSoundData*(f: float, len: float, rate: int, amplitude = 0.5'f32): SoundData = +proc SineSoundData*(f: float, len: float, rate: int, amplitude = 0.5'f32): SoundData = let dt = 1'f / float(rate) var sine = sinewave(f) for i in 0 ..< int(float(rate) * len): @@ -26,6 +26,6 @@ let value = int16(sine(t) * float(high(int16)) * amplitude) result.add [value, value] -proc newSound*(data: SoundData): Sound = +proc NewSound*(data: SoundData): Sound = result = new Sound result[] = data diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/color.nim --- a/semicongine/core/color.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/color.nim Tue Jun 04 20:51:22 2024 +0700 @@ -5,18 +5,18 @@ import ./vector -func colorToHex*(color: Vec3f): string = +func ColorToHex*(color: Vec3f): string = &"{int(color.r * 255):02X}{int(color.g * 255):02X}{int(color.b * 255):02X}" -func colorToHex*(color: Vec4f): string = +func ColorToHex*(color: Vec4f): string = &"{int(color.r * 255):02X}{int(color.g * 255):02X}{int(color.b * 255):02X}{int(color.a * 255):02X}" -func asPixel*(color: Vec3f): array[4, uint8] = +func AsPixel*(color: Vec3f): array[4, uint8] = [uint8(color.r * 255), uint8(color.g * 255), uint8(color.b * 255), 255'u8] -func asPixel*(color: Vec4f): array[4, uint8] = +func AsPixel*(color: Vec4f): array[4, uint8] = [uint8(color.r * 255), uint8(color.g * 255), uint8(color.b * 255), uint8(color.a * 255)] -func toRGBA*(value: string): Vec4f = +func ToRGBA*(value: string): Vec4f = assert value != "" var hex = value if hex[0] == '#': @@ -38,54 +38,54 @@ return Vec4f([float32(r), float32(g), float32(b), float32(a)]) / 255'f -func linear2srgb*(value: SomeFloat): SomeFloat = +func Linear2srgb*(value: SomeFloat): SomeFloat = clamp( if (value < 0.0031308): value * 12.92 else: pow(value, 1.0 / 2.4) * 1.055 - 0.055, 0, 1, ) -func srgb2linear*(value: SomeFloat): SomeFloat = +func Srgb2linear*(value: SomeFloat): SomeFloat = clamp( if (value < 0.04045): value / 12.92 else: pow((value + 0.055) / 1.055, 2.4), 0, 1, ) -func linear2srgb*(value: uint8): uint8 = # also covers GrayPixel - uint8(round(linear2srgb(float(value) / 255.0) * 255)) -func srgb2linear*(value: uint8): uint8 = # also covers GrayPixel - uint8(round(srgb2linear(float(value) / 255.0) * 255)) +func Linear2srgb*(value: uint8): uint8 = # also covers GrayPixel + uint8(round(Linear2srgb(float(value) / 255.0) * 255)) +func Srgb2linear*(value: uint8): uint8 = # also covers GrayPixel + uint8(round(Srgb2linear(float(value) / 255.0) * 255)) -func toSRGB*(value: Vec4f): Vec4f = +func ToSRGB*(value: Vec4f): Vec4f = NewVec4f( - linear2srgb(value.r), - linear2srgb(value.g), - linear2srgb(value.b), + Linear2srgb(value.r), + Linear2srgb(value.g), + Linear2srgb(value.b), value.a, ) -func fromSRGB*(value: Vec4f): Vec4f = +func FromSRGB*(value: Vec4f): Vec4f = NewVec4f( - srgb2linear(value.r), - srgb2linear(value.g), - srgb2linear(value.b), + Srgb2linear(value.r), + Srgb2linear(value.g), + Srgb2linear(value.b), value.a, ) const - Black* = toRGBA "#000000FF" - Silver* = toRGBA "#C0C0C0FF" - Gray* = toRGBA "#808080FF" - White* = toRGBA "#FFFFFFFF" - Maroon* = toRGBA "#800000FF" - Red* = toRGBA "#FF0000FF" - Purple* = toRGBA "#800080FF" - Fuchsia* = toRGBA "#FF00FFFF" - Green* = toRGBA "#008000FF" - Lime* = toRGBA "#00FF00FF" - Olive* = toRGBA "#808000FF" - Yellow* = toRGBA "#FFFF00FF" - Navy* = toRGBA "#000080FF" - Blue* = toRGBA "#0000FFFF" - Teal* = toRGBA "#008080FF" - Aqua* = toRGBA "#00FFFFFF" + Black* = ToRGBA "#000000FF" + Silver* = ToRGBA "#C0C0C0FF" + Gray* = ToRGBA "#808080FF" + White* = ToRGBA "#FFFFFFFF" + Maroon* = ToRGBA "#800000FF" + Red* = ToRGBA "#FF0000FF" + Purple* = ToRGBA "#800080FF" + Fuchsia* = ToRGBA "#FF00FFFF" + Green* = ToRGBA "#008000FF" + Lime* = ToRGBA "#00FF00FF" + Olive* = ToRGBA "#808000FF" + Yellow* = ToRGBA "#FFFF00FF" + Navy* = ToRGBA "#000080FF" + Blue* = ToRGBA "#0000FFFF" + Teal* = ToRGBA "#008080FF" + Aqua* = ToRGBA "#00FFFFFF" diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/dynamic_arrays.nim --- a/semicongine/core/dynamic_arrays.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/dynamic_arrays.nim Tue Jun 04 20:51:22 2024 +0700 @@ -56,10 +56,10 @@ of Mat4F64: mat4f64: ref seq[TMat4[float64]] of TextureType: texture: ref seq[Texture] -func size*(value: DataList): uint64 = - value.theType.size * value.len.uint64 +func Size*(value: DataList): uint64 = + value.theType.Size * value.len.uint64 -func hash*(value: DataList): Hash = +func Hash*(value: DataList): Hash = case value.theType of Float32: hash(value.float32) of Float64: hash(value.float64) @@ -153,7 +153,7 @@ of Mat4F64: return a.mat4f64 == b.mat4f64 of TextureType: a.texture == b.texture -proc setLen*(value: var DataList, len: int) = +proc SetLen*(value: var DataList, len: int) = value.len = len case value.theType of Float32: value.float32[].setLen(len) @@ -202,7 +202,7 @@ proc setValues[T: GPUType|int|uint|float](value: var DataList, data: openArray[T]) = - value.setLen(data.len) + value.SetLen(data.len) when T is float32: value.float32[] = @data elif T is float64: value.float64[] = @data elif T is int8: value.int8[] = @data @@ -307,7 +307,7 @@ elif T is Texture: value.texture[i] = data else: {.error: "Virtual datatype has no values".} -proc initDataList*(theType: DataType, len = 0): DataList = +proc InitDataList*(theType: DataType, len = 0): DataList = result = DataList(theType: theType) case result.theType of Float32: result.float32 = new seq[float32] @@ -353,14 +353,14 @@ of Mat4F32: result.mat4f32 = new seq[TMat4[float32]] of Mat4F64: result.mat4f64 = new seq[TMat4[float64]] of TextureType: result.texture = new seq[Texture] - result.setLen(len) + result.SetLen(len) -proc initDataList*[T: GPUType](len = 1): DataList = - result = initDataList(getDataType[T]()) - result.setLen(len) +proc InitDataList*[T: GPUType](len = 1): DataList = + result = InitDataList(GetDataType[T]()) + result.SetLen(len) -proc initDataList*[T: GPUType](data: openArray[T]): DataList = - result = initDataList(getDataType[T]()) +proc InitDataList*[T: GPUType](data: openArray[T]): DataList = + result = InitDataList(GetDataType[T]()) result.setValues(@data) func getValues[T: GPUType|int|uint|float](value: DataList): ref seq[T] = @@ -479,62 +479,62 @@ if table.contains(key): table[key].setValues(values) else: - table[key] = initDataList(values) + table[key] = InitDataList(values) template `[]=`*[T](list: var DataList, values: openArray[T]) = list.setValues(values) template `[]=`*[T](list: var DataList, i: int, value: T) = list.setValue(i, value) -func getPointer*(value: var DataList): pointer = +func GetPointer*(value: var DataList): pointer = if value.len == 0: result = nil case value.theType - of Float32: result = value.float32[].toCPointer - of Float64: result = value.float64[].toCPointer - of Int8: result = value.int8[].toCPointer - of Int16: result = value.int16[].toCPointer - of Int32: result = value.int32[].toCPointer - of Int64: result = value.int64[].toCPointer - of UInt8: result = value.uint8[].toCPointer - of UInt16: result = value.uint16[].toCPointer - of UInt32: result = value.uint32[].toCPointer - of UInt64: result = value.uint64[].toCPointer - of Vec2I32: result = value.vec2i32[].toCPointer - of Vec2I64: result = value.vec2i64[].toCPointer - of Vec3I32: result = value.vec3i32[].toCPointer - of Vec3I64: result = value.vec3i64[].toCPointer - of Vec4I32: result = value.vec4i32[].toCPointer - of Vec4I64: result = value.vec4i64[].toCPointer - of Vec2U32: result = value.vec2u32[].toCPointer - of Vec2U64: result = value.vec2u64[].toCPointer - of Vec3U32: result = value.vec3u32[].toCPointer - of Vec3U64: result = value.vec3u64[].toCPointer - of Vec4U32: result = value.vec4u32[].toCPointer - of Vec4U64: result = value.vec4u64[].toCPointer - of Vec2F32: result = value.vec2f32[].toCPointer - of Vec2F64: result = value.vec2f64[].toCPointer - of Vec3F32: result = value.vec3f32[].toCPointer - of Vec3F64: result = value.vec3f64[].toCPointer - of Vec4F32: result = value.vec4f32[].toCPointer - of Vec4F64: result = value.vec4f64[].toCPointer - of Mat2F32: result = value.mat2f32[].toCPointer - of Mat2F64: result = value.mat2f64[].toCPointer - of Mat23F32: result = value.mat23f32[].toCPointer - of Mat23F64: result = value.mat23f64[].toCPointer - of Mat32F32: result = value.mat32f32[].toCPointer - of Mat32F64: result = value.mat32f64[].toCPointer - of Mat3F32: result = value.mat3f32[].toCPointer - of Mat3F64: result = value.mat3f64[].toCPointer - of Mat34F32: result = value.mat34f32[].toCPointer - of Mat34F64: result = value.mat34f64[].toCPointer - of Mat43F32: result = value.mat43f32[].toCPointer - of Mat43F64: result = value.mat43f64[].toCPointer - of Mat4F32: result = value.mat4f32[].toCPointer - of Mat4F64: result = value.mat4f64[].toCPointer + of Float32: result = value.float32[].ToCPointer + of Float64: result = value.float64[].ToCPointer + of Int8: result = value.int8[].ToCPointer + of Int16: result = value.int16[].ToCPointer + of Int32: result = value.int32[].ToCPointer + of Int64: result = value.int64[].ToCPointer + of UInt8: result = value.uint8[].ToCPointer + of UInt16: result = value.uint16[].ToCPointer + of UInt32: result = value.uint32[].ToCPointer + of UInt64: result = value.uint64[].ToCPointer + of Vec2I32: result = value.vec2i32[].ToCPointer + of Vec2I64: result = value.vec2i64[].ToCPointer + of Vec3I32: result = value.vec3i32[].ToCPointer + of Vec3I64: result = value.vec3i64[].ToCPointer + of Vec4I32: result = value.vec4i32[].ToCPointer + of Vec4I64: result = value.vec4i64[].ToCPointer + of Vec2U32: result = value.vec2u32[].ToCPointer + of Vec2U64: result = value.vec2u64[].ToCPointer + of Vec3U32: result = value.vec3u32[].ToCPointer + of Vec3U64: result = value.vec3u64[].ToCPointer + of Vec4U32: result = value.vec4u32[].ToCPointer + of Vec4U64: result = value.vec4u64[].ToCPointer + of Vec2F32: result = value.vec2f32[].ToCPointer + of Vec2F64: result = value.vec2f64[].ToCPointer + of Vec3F32: result = value.vec3f32[].ToCPointer + of Vec3F64: result = value.vec3f64[].ToCPointer + of Vec4F32: result = value.vec4f32[].ToCPointer + of Vec4F64: result = value.vec4f64[].ToCPointer + of Mat2F32: result = value.mat2f32[].ToCPointer + of Mat2F64: result = value.mat2f64[].ToCPointer + of Mat23F32: result = value.mat23f32[].ToCPointer + of Mat23F64: result = value.mat23f64[].ToCPointer + of Mat32F32: result = value.mat32f32[].ToCPointer + of Mat32F64: result = value.mat32f64[].ToCPointer + of Mat3F32: result = value.mat3f32[].ToCPointer + of Mat3F64: result = value.mat3f64[].ToCPointer + of Mat34F32: result = value.mat34f32[].ToCPointer + of Mat34F64: result = value.mat34f64[].ToCPointer + of Mat43F32: result = value.mat43f32[].ToCPointer + of Mat43F64: result = value.mat43f64[].ToCPointer + of Mat4F32: result = value.mat4f32[].ToCPointer + of Mat4F64: result = value.mat4f64[].ToCPointer of TextureType: nil -proc appendValues*[T: GPUType|int|uint|float](value: var DataList, data: openArray[T]) = +proc AppendValues*[T: GPUType|int|uint|float](value: var DataList, data: openArray[T]) = value.len += data.len when T is float32: value.float32[].add @data elif T is float64: value.float64[].add @data @@ -587,7 +587,7 @@ elif T is Texture: value.texture[].add @data else: {.error: "Virtual datatype has no values".} -proc appendValues*(value: var DataList, data: DataList) = +proc AppendValues*(value: var DataList, data: DataList) = assert value.theType == data.theType, &"Expected datalist of type {value.theType} but got {data.theType}" value.len += data.len case value.theType: @@ -635,7 +635,7 @@ of Mat4F64: value.mat4f64[].add data.mat4f64[] of TextureType: value.texture[].add data.texture[] -proc appendFrom*(a: var DataList, i: int, b: DataList, j: int) = +proc AppendFrom*(a: var DataList, i: int, b: DataList, j: int) = assert a.theType == b.theType case a.theType of Float32: a.float32[i] = b.float32[j] @@ -682,9 +682,9 @@ of Mat4F64: a.mat4f64[i] = b.mat4f64[j] of TextureType: a.texture[i] = b.texture[j] -proc copy*(datalist: DataList): DataList = - result = initDataList(datalist.theType) - result.appendValues(datalist) +proc Copy*(datalist: DataList): DataList = + result = InitDataList(datalist.theType) + result.AppendValues(datalist) func `$`*(list: DataList): string = case list.theType diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/gpu_types.nim --- a/semicongine/core/gpu_types.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/gpu_types.nim Tue Jun 04 20:51:22 2024 +0700 @@ -71,24 +71,24 @@ result &= &", {attr.arrayCount}" result &= "]" -func vertexInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = +func VertexInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = for attr in attributes: if attr.perInstance == false: result.add attr -func instanceInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = +func InstanceInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = for attr in attributes: if attr.perInstance == false: result.add attr -func numberOfVertexInputAttributeDescriptors*(theType: DataType): uint = +func NumberOfVertexInputAttributeDescriptors*(theType: DataType): uint = case theType: of Mat2F32, Mat2F64, Mat23F32, Mat23F64: 2 of Mat32F32, Mat32F64, Mat3F32, Mat3F64, Mat34F32, Mat34F64: 3 of Mat43F32, Mat43F64, Mat4F32, Mat4F64: 4 else: 1 -func size*(theType: DataType): uint64 = +func Size*(theType: DataType): uint64 = case theType: of Float32: 4 of Float64: 8 @@ -134,20 +134,20 @@ of Mat4F64: 128 of TextureType: 0 -func size*(attribute: ShaderAttribute, perDescriptor = false): uint64 = +func Size*(attribute: ShaderAttribute, perDescriptor = false): uint64 = if perDescriptor: - attribute.theType.size div attribute.theType.numberOfVertexInputAttributeDescriptors + attribute.theType.Size div attribute.theType.NumberOfVertexInputAttributeDescriptors else: if attribute.arrayCount == 0: - attribute.theType.size + attribute.theType.Size else: - attribute.theType.size * attribute.arrayCount + attribute.theType.Size * attribute.arrayCount -func size*(theType: seq[ShaderAttribute]): uint64 = +func Size*(theType: seq[ShaderAttribute]): uint64 = for attribute in theType: - result += attribute.size + result += attribute.Size -func getDataType*[T: GPUType|int|uint|float](): DataType = +func GetDataType*[T: GPUType|int|uint|float](): DataType = when T is float32: Float32 elif T is float64: Float64 elif T is int8: Int8 @@ -201,7 +201,7 @@ static: raise newException(Exception, &"Unsupported data type for GPU data: {name(T)}") -func attr*[T: GPUType]( +func Attr*[T: GPUType]( name: string, perInstance = false, arrayCount = 0'u32, @@ -210,7 +210,7 @@ ): auto = ShaderAttribute( name: name, - theType: getDataType[T](), + theType: GetDataType[T](), perInstance: perInstance, arrayCount: arrayCount, noInterpolation: noInterpolation, @@ -262,11 +262,11 @@ Mat4F64: VK_FORMAT_R64G64B64A64_SFLOAT, }.toTable -func getVkFormat*(theType: DataType): VkFormat = +func GetVkFormat*(theType: DataType): VkFormat = TYPEMAP[theType] # from https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap15.html -func nLocationSlots*(theType: DataType): int = +func NLocationSlots*(theType: DataType): int = #[ single location: 16-bit scalar and vector types, and @@ -320,7 +320,7 @@ of Mat4F64: 2 of TextureType: 1 -func glslType*(theType: DataType): string = +func GlslType*(theType: DataType): string = # todo: likely not correct as we would need to enable some # extensions somewhere (Vulkan/GLSL compiler?) to have # everything work as intended. Or maybe the GPU driver does @@ -364,23 +364,23 @@ of Mat4F64: "dmat4" of TextureType: "sampler2D" -func glslInput*(group: openArray[ShaderAttribute]): seq[string] = +func GlslInput*(group: openArray[ShaderAttribute]): seq[string] = if group.len == 0: return @[] var i = 0 for attribute in group: assert attribute.arrayCount == 0, "arrays not supported for shader vertex attributes" let flat = if attribute.noInterpolation: "flat " else: "" - result.add &"layout(location = {i}) {flat}in {attribute.theType.glslType} {attribute.name};" - for j in 0 ..< attribute.theType.numberOfVertexInputAttributeDescriptors: - i += attribute.theType.nLocationSlots + result.add &"layout(location = {i}) {flat}in {attribute.theType.GlslType} {attribute.name};" + for j in 0 ..< attribute.theType.NumberOfVertexInputAttributeDescriptors: + i += attribute.theType.NLocationSlots -func glslUniforms*(group: openArray[ShaderAttribute], blockName = "Uniforms", binding: int): seq[string] = +func GlslUniforms*(group: openArray[ShaderAttribute], blockName = "Uniforms", binding: int): seq[string] = if group.len == 0: return @[] for uniform in group: if uniform.arrayCount > 0: - assert uniform.theType.size mod 16 == 0, &"Uniform '{uniform.name}': Array elements in a uniform block must align to 16 but current size is {uniform.theType.size} (until we can two different shaders)" + assert uniform.theType.Size mod 16 == 0, &"Uniform '{uniform.name}': Array elements in a uniform block must align to 16 but current size is {uniform.theType.Size} (until we can two different shaders)" # TODO: read the lines below, having at least std430 would be nice... # currently only a single uniform block supported, therefore binding = 0 # Also, we might need to figure out how we can ship std430 on newer hardware and normal on older? @@ -388,15 +388,15 @@ result.add(&"layout(binding = {binding}) uniform T{blockName} {{") var last_size = high(uint64) for attribute in group: - assert attribute.size <= last_size, &"The attribute '{attribute.name}' is bigger than the attribute before, which is not allowed" # using smaller uniform-types first will lead to problems (I think due to alignment, there is also some stuff on the internet about this ;) + assert attribute.Size <= last_size, &"The attribute '{attribute.name}' is bigger than the attribute before, which is not allowed" # using smaller uniform-types first will lead to problems (I think due to alignment, there is also some stuff on the internet about this ;) var arrayDecl = "" if attribute.arrayCount > 0: arrayDecl = &"[{attribute.arrayCount}]" - result.add(&" {attribute.theType.glslType} {attribute.name}{arrayDecl};") - last_size = attribute.size + result.add(&" {attribute.theType.GlslType} {attribute.name}{arrayDecl};") + last_size = attribute.Size result.add(&"}} {blockName};") -func glslSamplers*(group: openArray[ShaderAttribute], basebinding: int): seq[string] = +func GlslSamplers*(group: openArray[ShaderAttribute], basebinding: int): seq[string] = if group.len == 0: return @[] var thebinding = basebinding @@ -404,15 +404,15 @@ var arrayDecl = "" if attribute.arrayCount > 0: arrayDecl = &"[{attribute.arrayCount}]" - result.add(&"layout(binding = {thebinding}) uniform {attribute.theType.glslType} {attribute.name}{arrayDecl};") + result.add(&"layout(binding = {thebinding}) uniform {attribute.theType.GlslType} {attribute.name}{arrayDecl};") inc thebinding -func glslOutput*(group: openArray[ShaderAttribute]): seq[string] = +func GlslOutput*(group: openArray[ShaderAttribute]): seq[string] = if group.len == 0: return @[] var i = 0 for attribute in group: assert attribute.arrayCount == 0, "arrays not supported for outputs" let flat = if attribute.noInterpolation: "flat " else: "" - result.add &"layout(location = {i}) {flat}out {attribute.theType.glslType} {attribute.name};" + result.add &"layout(location = {i}) {flat}out {attribute.theType.GlslType} {attribute.name};" i += 1 diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/imagetypes.nim --- a/semicongine/core/imagetypes.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/imagetypes.nim Tue Jun 04 20:51:22 2024 +0700 @@ -34,27 +34,27 @@ else: return a.colorImage == b.colorImage -converter toRGBA*(p: RGBAPixel): Vec4f = +converter ToRGBA*(p: RGBAPixel): Vec4f = NewVec4f(float32(p[0]) / 255'f32, float32(p[1]) / 255'f32, float32(p[2]) / 255'f32, float32(p[3]) / 255'f32) -converter toGrayscale*(p: GrayPixel): float32 = +converter ToGrayscale*(p: GrayPixel): float32 = float32(p) / 255'f32 # colorspace conversion functions -func linear2srgb*(value: RGBAPixel): RGBAPixel = - [linear2srgb(value[0]), linear2srgb(value[1]), linear2srgb(value[2]), value[3]] -func srgb2linear*(value: RGBAPixel): RGBAPixel = - [srgb2linear(value[0]), srgb2linear(value[1]), srgb2linear(value[2]), value[3]] +func Linear2srgb*(value: RGBAPixel): RGBAPixel = + [Linear2srgb(value[0]), Linear2srgb(value[1]), Linear2srgb(value[2]), value[3]] +func Srgb2linear*(value: RGBAPixel): RGBAPixel = + [Srgb2linear(value[0]), Srgb2linear(value[1]), Srgb2linear(value[2]), value[3]] -proc asSRGB*[T](image: Image[T]): Image[T] = +proc AsSRGB*[T](image: Image[T]): Image[T] = result = Image[T](width: image.width, height: image.height, imagedata: newSeq[T](image.imagedata.len)) for i in 0 .. image.imagedata.len: - result.imagedata[i] = linear2srgb(image.imagedata[i]) + result.imagedata[i] = Linear2srgb(image.imagedata[i]) -proc asLinear*[T](image: Image[T]): Image[T] = +proc AsLinear*[T](image: Image[T]): Image[T] = result = Image[T](width: image.width, height: image.height, imagedata: newSeq[T](image.imagedata.len)) for i in 0 ..< image.imagedata.len: - result.imagedata[i] = srgb2linear(image.imagedata[i]) + result.imagedata[i] = Srgb2linear(image.imagedata[i]) proc `$`*(image: Image): string = &"{image.width}x{image.height}" @@ -77,7 +77,7 @@ image[].imagedata[y * image.width + x] = value -proc newImage*[T: Pixel](width, height: uint32, imagedata: openArray[T] = []): Image[T] = +proc NewImage*[T: Pixel](width, height: uint32, imagedata: openArray[T] = []): Image[T] = assert width > 0 and height > 0 assert imagedata.len.uint32 == width * height or imagedata.len == 0 @@ -102,5 +102,5 @@ wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT, ) let - INVALID_TEXTURE* = Texture(name: "Invalid texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 0'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER) - EMPTY_TEXTURE* = Texture(name: "Empty texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER) + INVALID_TEXTURE* = Texture(name: "Invalid texture", isGrayscale: false, colorImage: NewImage(1, 1, @[[255'u8, 0'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER) + EMPTY_TEXTURE* = Texture(name: "Empty texture", isGrayscale: false, colorImage: NewImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/core/utils.nim --- a/semicongine/core/utils.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/core/utils.nim Tue Jun 04 20:51:22 2024 +0700 @@ -14,16 +14,16 @@ Center Bottom -func cleanString*(str: openArray[char]): string = +func CleanString*(str: openArray[char]): string = for i in 0 ..< len(str): if str[i] == char(0): result = join(str[0 ..< i]) break -func toCPointer*[T](list: openArray[T]): ptr T = +func ToCPointer*[T](list: openArray[T]): ptr T = if list.len > 0: addr(list[0]) else: nil -proc staticExecChecked*(command: string, input = ""): string {.compileTime.} = +proc StaticExecChecked*(command: string, input = ""): string {.compileTime.} = let (output, exitcode) = gorgeEx( command = command, input = input) @@ -34,5 +34,5 @@ proc AppName*(): string = return string(Path(getAppFilename()).splitFile.name) -func size*[T: seq](list: T): uint64 = +func Size*[T: seq](list: T): uint64 = uint64(list.len * sizeof(get(genericParams(typeof(list)), 0))) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/material.nim --- a/semicongine/material.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/material.nim Tue Jun 04 20:51:22 2024 +0700 @@ -135,10 +135,10 @@ EMPTY_SHADER* = createShaderConfiguration( name = "empty shader", inputs = [ - attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), ], - outputs = [attr[Vec4f]("color")], + outputs = [Attr[Vec4f]("color")], vertexCode = &"gl_Position = vec4(position, 1.0) * {TRANSFORM_ATTRIB};", fragmentCode = &"color = vec4(1, 0, 1, 1);" ) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/mesh.nim --- a/semicongine/mesh.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/mesh.nim Tue Jun 04 20:51:22 2024 +0700 @@ -99,8 +99,8 @@ proc initVertexAttribute*[T](mesh: var MeshObject, attribute: string, value: seq[T]) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) - mesh.vertexData[attribute] = initDataList(thetype = getDataType[T]()) - mesh.vertexData[attribute].setLen(mesh.vertexCount) + mesh.vertexData[attribute] = InitDataList(thetype = GetDataType[T]()) + mesh.vertexData[attribute].SetLen(mesh.vertexCount) mesh.vertexData[attribute] = value proc initVertexAttribute*[T](mesh: var MeshObject, attribute: string, value: T) = initVertexAttribute(mesh, attribute, newSeqWith(mesh.vertexCount, value)) @@ -108,8 +108,8 @@ initVertexAttribute(mesh = mesh, attribute = attribute, value = default(T)) proc initVertexAttribute*(mesh: var MeshObject, attribute: string, datatype: DataType) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) - mesh.vertexData[attribute] = initDataList(thetype = datatype) - mesh.vertexData[attribute].setLen(mesh.vertexCount) + mesh.vertexData[attribute] = InitDataList(thetype = datatype) + mesh.vertexData[attribute].SetLen(mesh.vertexCount) proc initVertexAttribute*(mesh: var MeshObject, attribute: string, data: DataList) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) mesh.vertexData[attribute] = data @@ -117,8 +117,8 @@ proc initInstanceAttribute*[T](mesh: var MeshObject, attribute: string, value: seq[T]) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) - mesh.instanceData[attribute] = initDataList(thetype = getDataType[T]()) - mesh.instanceData[attribute].setLen(mesh.instanceCount) + mesh.instanceData[attribute] = InitDataList(thetype = GetDataType[T]()) + mesh.instanceData[attribute].SetLen(mesh.instanceCount) mesh.instanceData[attribute] = value proc initInstanceAttribute*[T](mesh: var MeshObject, attribute: string, value: T) = initInstanceAttribute(mesh, attribute, newSeqWith(mesh.instanceCount, value)) @@ -126,8 +126,8 @@ initInstanceAttribute(mesh = mesh, attribute = attribute, value = default(T)) proc initInstanceAttribute*(mesh: var MeshObject, attribute: string, datatype: DataType) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) - mesh.instanceData[attribute] = initDataList(thetype = datatype) - mesh.instanceData[attribute].setLen(mesh.instanceCount) + mesh.instanceData[attribute] = InitDataList(thetype = datatype) + mesh.instanceData[attribute].SetLen(mesh.instanceCount) proc initInstanceAttribute*(mesh: var MeshObject, attribute: string, data: DataList) = assert not mesh.vertexData.contains(attribute) and not mesh.instanceData.contains(attribute) mesh.instanceData[attribute] = data @@ -211,9 +211,9 @@ func attributeSize*(mesh: MeshObject, attribute: string): uint64 = if mesh.vertexData.contains(attribute): - mesh.vertexData[attribute].size + mesh.vertexData[attribute].Size elif mesh.instanceData.contains(attribute): - mesh.instanceData[attribute].size + mesh.instanceData[attribute].Size else: 0 @@ -247,9 +247,9 @@ func getPointer*(mesh: var MeshObject, attribute: string): pointer = if mesh.vertexData.contains(attribute): - mesh.vertexData[attribute].getPointer() + mesh.vertexData[attribute].GetPointer() elif mesh.instanceData.contains(attribute): - mesh.instanceData[attribute].getPointer() + mesh.instanceData[attribute].GetPointer() else: raise newException(Exception, &"Attribute {attribute} is not defined for mesh {mesh}") @@ -421,29 +421,29 @@ for attribute, datalist in mesh.vertexData.pairs: result.initVertexAttribute(attribute, datalist.theType) for attribute, datalist in mesh.instanceData.pairs: - result.instanceData[attribute] = datalist.copy() + result.instanceData[attribute] = datalist.Copy() var i = 0 case mesh.indexType of Tiny: for indices in mesh.tinyIndices: for attribute, value in mesh.vertexData.pairs: - result.vertexData[attribute].appendFrom(i, mesh.vertexData[attribute], int(indices[0])) - result.vertexData[attribute].appendFrom(i + 1, mesh.vertexData[attribute], int(indices[1])) - result.vertexData[attribute].appendFrom(i + 2, mesh.vertexData[attribute], int(indices[2])) + result.vertexData[attribute].AppendFrom(i, mesh.vertexData[attribute], int(indices[0])) + result.vertexData[attribute].AppendFrom(i + 1, mesh.vertexData[attribute], int(indices[1])) + result.vertexData[attribute].AppendFrom(i + 2, mesh.vertexData[attribute], int(indices[2])) i += 3 of Small: for indices in mesh.smallIndices: for attribute, value in mesh.vertexData.pairs: - result.vertexData[attribute].appendFrom(i, value, int(indices[0])) - result.vertexData[attribute].appendFrom(i + 1, value, int(indices[1])) - result.vertexData[attribute].appendFrom(i + 2, value, int(indices[2])) + result.vertexData[attribute].AppendFrom(i, value, int(indices[0])) + result.vertexData[attribute].AppendFrom(i + 1, value, int(indices[1])) + result.vertexData[attribute].AppendFrom(i + 2, value, int(indices[2])) i += 3 of Big: for indices in mesh.bigIndices: for attribute, value in mesh.vertexData.pairs: - result.vertexData[attribute].appendFrom(i, mesh.vertexData[attribute], int(indices[0])) - result.vertexData[attribute].appendFrom(i + 1, mesh.vertexData[attribute], int(indices[1])) - result.vertexData[attribute].appendFrom(i + 2, mesh.vertexData[attribute], int(indices[2])) + result.vertexData[attribute].AppendFrom(i, mesh.vertexData[attribute], int(indices[0])) + result.vertexData[attribute].AppendFrom(i + 1, mesh.vertexData[attribute], int(indices[1])) + result.vertexData[attribute].AppendFrom(i + 2, mesh.vertexData[attribute], int(indices[2])) i += 3 else: discard @@ -466,7 +466,7 @@ half_w = width / 2 half_h = height / 2 pos = @[NewVec3f(-half_w, -half_h), NewVec3f(half_w, -half_h), NewVec3f(half_w, half_h), NewVec3f(-half_w, half_h)] - c = toRGBA(color) + c = ToRGBA(color) result[].initVertexAttribute(DEFAULT_POSITION_ATTRIBUTE, pos) result[].initVertexAttribute("color", @[c, c, c, c]) @@ -483,7 +483,7 @@ let half_w = width / 2 half_h = height / 2 - colorVec = toRGBA(color) + colorVec = ToRGBA(color) result[].initVertexAttribute(DEFAULT_POSITION_ATTRIBUTE, @[NewVec3f(0, -half_h), NewVec3f(half_w, half_h), NewVec3f(-half_w, half_h)]) result[].initVertexAttribute("color", @[colorVec, colorVec, colorVec]) @@ -512,7 +512,7 @@ let rX = width / 2 rY = height / 2 - c = toRGBA(color) + c = ToRGBA(color) step = (2'f32 * PI) / float32(nSegments) var pos = @[NewVec3f(0, 0), NewVec3f(rX, 0)] @@ -554,7 +554,7 @@ inc instanceCounter let - color = toRGBA(color) + color = ToRGBA(color) center_offset_x = -(float32(columns) * cellSize) / 2'f32 center_offset_y = -(float32(rows) * cellSize) / 2'f32 var @@ -581,7 +581,7 @@ for key in a.vertexData.keys: assert key in b.vertexData, &"Mesh {b} is missing vertex data for '{key}'" for (key, value) in b.vertexData.pairs: - a.vertexData[key].appendValues(value) + a.vertexData[key].AppendValues(value) case a.indexType: of None: diff -r 71315636ba82 -r a4aa9f374d44 semicongine/panel.nim --- a/semicongine/panel.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/panel.nim Tue Jun 04 20:51:22 2024 +0700 @@ -22,18 +22,18 @@ PANEL_SHADER* = createShaderConfiguration( name = "panel shader", inputs = [ - attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), - attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite), - attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite), - attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), + Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), + Attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite), + Attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite), + Attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), ], intermediates = [ - attr[Vec2f]("uvFrag"), - attr[uint16]("materialIndexOut", noInterpolation = true) + Attr[Vec2f]("uvFrag"), + Attr[uint16]("materialIndexOut", noInterpolation = true) ], - outputs = [attr[Vec4f]("color")], - uniforms = [attr[Vec4f]("color", arrayCount = MAX_PANEL_MATERIALS), attr[float32](ASPECT_RATIO_ATTRIBUTE)], - samplers = [attr[Texture]("panelTexture", arrayCount = MAX_PANEL_MATERIALS)], + outputs = [Attr[Vec4f]("color")], + uniforms = [Attr[Vec4f]("color", arrayCount = MAX_PANEL_MATERIALS), Attr[float32](ASPECT_RATIO_ATTRIBUTE)], + samplers = [Attr[Texture]("panelTexture", arrayCount = MAX_PANEL_MATERIALS)], vertexCode = &""" gl_Position = vec4({POSITION_ATTRIB}.x, {POSITION_ATTRIB}.y * Uniforms.{ASPECT_RATIO_ATTRIBUTE}, {POSITION_ATTRIB}.z, 1.0) * {TRANSFORM_ATTRIB}; uvFrag = {UV_ATTRIB}; @@ -123,7 +123,7 @@ result.mesh.material = initMaterialData( theType = PANEL_MATERIAL_TYPE, name = "Panel material", - attributes = {"panelTexture": initDataList(@[texture]), "color": initDataList(@[color])}, + attributes = {"panelTexture": InitDataList(@[texture]), "color": InitDataList(@[color])}, ) inc instanceCounter result.refresh() diff -r 71315636ba82 -r a4aa9f374d44 semicongine/renderer.nim --- a/semicongine/renderer.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/renderer.nim Tue Jun 04 20:51:22 2024 +0700 @@ -248,7 +248,7 @@ # gather uniform sizes var uniformBufferSize = 0'u64 for uniform in shaderPipeline.uniforms: - uniformBufferSize += uniform.size + uniformBufferSize += uniform.Size if uniformBufferSize > 0: for frame_i in 0 ..< renderer.swapchain.inFlightFrames: scenedata.shaderData[shaderPipeline.vk].uniformBuffers.add renderer.device.createBuffer( @@ -343,7 +343,7 @@ # loop over all uniforms of the shader-shaderPipeline for uniform in shaderPipeline.uniforms: if dirty.contains(uniform.name) or dirtyMaterialAttribs.contains(uniform.name) or forceAll: # only update uniforms if necessary - var value = initDataList(uniform.theType) + var value = InitDataList(uniform.theType) if scene.shaderGlobals.hasKey(uniform.name): assert scene.shaderGlobals[uniform.name].thetype == uniform.thetype value = scene.shaderGlobals[uniform.name] @@ -351,22 +351,22 @@ var foundValue = false for material in renderer.scenedata[scene].materials[materialType]: if material.hasMatchingAttribute(uniform): - value.appendValues(material[uniform.name]) + value.AppendValues(material[uniform.name]) foundValue = true assert foundValue, &"Uniform '{uniform.name}' not found in scene shaderGlobals or materials" assert (uniform.arrayCount == 0 and value.len == 1) or value.len.uint <= uniform.arrayCount, &"Uniform '{uniform.name}' found has wrong length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})" if value.len.uint <= uniform.arrayCount: debug &"Uniform '{uniform.name}' found has short length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})" - assert value.size <= uniform.size, &"During uniform update: gathered value has size {value.size} but uniform expects size {uniform.size}" - if value.size < uniform.size: - debug &"During uniform update: gathered value has size {value.size} but uniform expects size {uniform.size}" + assert value.Size <= uniform.Size, &"During uniform update: gathered value has size {value.Size} but uniform expects size {uniform.Size}" + if value.Size < uniform.Size: + debug &"During uniform update: gathered value has size {value.Size} but uniform expects size {uniform.Size}" debug &" update uniform '{uniform.name}' with value: {value}" # TODO: technically we would only need to update the uniform buffer of the current # frameInFlight (I think), but we don't track for which frame the shaderglobals are no longer dirty # therefore we have to update the uniform values in all buffers, of all inFlightframes (usually 2) for buffer in renderer.scenedata[scene].shaderData[shaderPipeline.vk].uniformBuffers: - buffer.setData(renderer.queue, value.getPointer(), value.size, offset) - offset += uniform.size + buffer.setData(renderer.queue, value.GetPointer(), value.Size, offset) + offset += uniform.Size scene.clearDirtyShaderGlobals() proc startNewFrame*(renderer: var Renderer) = diff -r 71315636ba82 -r a4aa9f374d44 semicongine/resources/font.nim --- a/semicongine/resources/font.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/resources/font.nim Tue Jun 04 20:51:22 2024 +0700 @@ -55,7 +55,7 @@ var topOffsets: Table[Rune, int] images: seq[Image[GrayPixel]] - let empty_image = newImage[GrayPixel](1, 1, [0'u8]) + let empty_image = NewImage[GrayPixel](1, 1, [0'u8]) for codePoint in codePoints: var @@ -81,7 +81,7 @@ var bitmap = newSeq[GrayPixel](width * height) for i in 0 ..< width * height: bitmap[i] = GrayPixel(data[i]) - images.add newImage[GrayPixel](width.uint32, height.uint32, bitmap) + images.add NewImage[GrayPixel](width.uint32, height.uint32, bitmap) else: images.add empty_image diff -r 71315636ba82 -r a4aa9f374d44 semicongine/resources/image.nim --- a/semicongine/resources/image.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/resources/image.nim Tue Jun 04 20:51:22 2024 +0700 @@ -104,7 +104,7 @@ data[row_mult * dibHeader.width + col] = pixel stream.setPosition(stream.getPosition() + padding) - result = newImage(width = dibHeader.width.uint32, height = abs(dibHeader.height).uint32, imagedata = data) + result = NewImage(width = dibHeader.width.uint32, height = abs(dibHeader.height).uint32, imagedata = data) {.compile: currentSourcePath.parentDir() & "/lodepng.c".} @@ -127,7 +127,7 @@ free(data) - result = newImage(width = w, height = h, imagedata = imagedata) + result = NewImage(width = w, height = h, imagedata = imagedata) proc toPNG*[T: Pixel](image: Image[T]): seq[uint8] = when T is GrayPixel: @@ -143,7 +143,7 @@ let ret = lodepng_encode_memory( addr pngData, addr pngSize, - cast[cstring](image.imagedata.toCPointer), + cast[cstring](image.imagedata.ToCPointer), cuint(image.width), cuint(image.height), cint(pngType), diff -r 71315636ba82 -r a4aa9f374d44 semicongine/resources/mesh.nim --- a/semicongine/resources/mesh.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/resources/mesh.nim Tue Jun 04 20:51:22 2024 +0700 @@ -104,8 +104,8 @@ copyMem(dstPointer, addr mainBuffer[bufferOffset], result.len) proc getAccessorData(root: JsonNode, accessor: JsonNode, mainBuffer: seq[uint8]): DataList = - result = initDataList(thetype = accessor.getGPUType("??")) - result.setLen(accessor["count"].getInt()) + result = InitDataList(thetype = accessor.getGPUType("??")) + result.SetLen(accessor["count"].getInt()) let bufferView = root["bufferViews"][accessor["bufferView"].getInt()] assert bufferView["buffer"].getInt() == 0, "Currently no external buffers supported" @@ -116,14 +116,14 @@ let accessorOffset = if accessor.hasKey("byteOffset"): accessor["byteOffset"].getInt() else: 0 let length = bufferView["byteLength"].getInt() let bufferOffset = bufferView["byteOffset"].getInt() + accessorOffset - var dstPointer = result.getPointer() + var dstPointer = result.GetPointer() if bufferView.hasKey("byteStride"): warn "Congratulations, you try to test a feature (loading buffer data with stride attributes) that we have no idea where it is used and how it can be tested (need a coresponding *.glb file)." # we don't support stride, have to convert stuff here... does this even work? for i in 0 ..< int(result.len): - copyMem(dstPointer, addr mainBuffer[bufferOffset + i * bufferView["byteStride"].getInt()], int(result.thetype.size)) - dstPointer = cast[pointer](cast[uint](dstPointer) + result.thetype.size) + copyMem(dstPointer, addr mainBuffer[bufferOffset + i * bufferView["byteStride"].getInt()], int(result.thetype.Size)) + dstPointer = cast[pointer](cast[uint](dstPointer) + result.thetype.Size) else: copyMem(dstPointer, addr mainBuffer[bufferOffset], length) @@ -169,7 +169,7 @@ # color if defaultMaterial.attributes.contains("color"): - attributes["color"] = initDataList(thetype = Vec4F32) + attributes["color"] = InitDataList(thetype = Vec4F32) if pbr.hasKey(GLTF_MATERIAL_MAPPING["color"]): attributes["color"] = @[NewVec4f( pbr[GLTF_MATERIAL_MAPPING["color"]][0].getFloat(), @@ -183,7 +183,7 @@ # pbr material values for factor in ["metallic", "roughness"]: if defaultMaterial.attributes.contains(factor): - attributes[factor] = initDataList(thetype = Float32) + attributes[factor] = InitDataList(thetype = Float32) if pbr.hasKey(GLTF_MATERIAL_MAPPING[factor]): attributes[factor] = @[float32(pbr[GLTF_MATERIAL_MAPPING[factor]].getFloat())] else: @@ -192,8 +192,8 @@ # pbr material textures for texture in ["baseTexture", "metallicRoughnessTexture"]: if defaultMaterial.attributes.contains(texture): - attributes[texture] = initDataList(thetype = TextureType) - # attributes[texture & "Index"] = initDataList(thetype=UInt8) + attributes[texture] = InitDataList(thetype = TextureType) + # attributes[texture & "Index"] = InitDataList(thetype=UInt8) if pbr.hasKey(GLTF_MATERIAL_MAPPING[texture]): attributes[texture] = @[loadTexture(root, pbr[GLTF_MATERIAL_MAPPING[texture]]["index"].getInt(), mainBuffer)] else: @@ -202,8 +202,8 @@ # generic material textures for texture in ["normalTexture", "occlusionTexture", "emissiveTexture"]: if defaultMaterial.attributes.contains(texture): - attributes[texture] = initDataList(thetype = TextureType) - # attributes[texture & "Index"] = initDataList(thetype=UInt8) + attributes[texture] = InitDataList(thetype = TextureType) + # attributes[texture & "Index"] = InitDataList(thetype=UInt8) if materialNode.hasKey(GLTF_MATERIAL_MAPPING[texture]): attributes[texture] = @[loadTexture(root, materialNode[texture]["index"].getInt(), mainBuffer)] else: @@ -211,7 +211,7 @@ # emissiv color if defaultMaterial.attributes.contains("emissiveColor"): - attributes["emissiveColor"] = initDataList(thetype = Vec3F32) + attributes["emissiveColor"] = InitDataList(thetype = Vec3F32) if materialNode.hasKey(GLTF_MATERIAL_MAPPING["emissiveColor"]): attributes["emissiveColor"] = @[NewVec3f( materialNode[GLTF_MATERIAL_MAPPING["emissiveColor"]][0].getFloat(), diff -r 71315636ba82 -r a4aa9f374d44 semicongine/scene.nim --- a/semicongine/scene.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/scene.nim Tue Jun 04 20:51:22 2024 +0700 @@ -45,7 +45,7 @@ proc addShaderGlobalArray*[T](scene: var Scene, name: string, data: openArray[T]) = assert not scene.loaded, &"Scene {scene.name} has already been loaded, cannot add shader values" - scene.shaderGlobals[name] = initDataList(data) + scene.shaderGlobals[name] = InitDataList(data) scene.dirtyShaderGlobals.add name proc addShaderGlobal*[T](scene: var Scene, name: string, data: T) = diff -r 71315636ba82 -r a4aa9f374d44 semicongine/text.nim --- a/semicongine/text.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/text.nim Tue Jun 04 20:51:22 2024 +0700 @@ -26,18 +26,18 @@ TEXT_SHADER* = createShaderConfiguration( name = "font shader", inputs = [ - attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), - attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite), - attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite), - attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), + Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), + Attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite), + Attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite), + Attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), ], intermediates = [ - attr[Vec2f]("uvFrag"), - attr[uint16]("materialIndexOut", noInterpolation = true) + Attr[Vec2f]("uvFrag"), + Attr[uint16]("materialIndexOut", noInterpolation = true) ], - outputs = [attr[Vec4f]("color")], - uniforms = [attr[Vec4f]("color", arrayCount = MAX_TEXT_MATERIALS), attr[float32](ASPECT_RATIO_ATTRIBUTE)], - samplers = [attr[Texture]("fontAtlas", arrayCount = MAX_TEXT_MATERIALS)], + outputs = [Attr[Vec4f]("color")], + uniforms = [Attr[Vec4f]("color", arrayCount = MAX_TEXT_MATERIALS), Attr[float32](ASPECT_RATIO_ATTRIBUTE)], + samplers = [Attr[Texture]("fontAtlas", arrayCount = MAX_TEXT_MATERIALS)], vertexCode = &""" gl_Position = vec4({POSITION_ATTRIB}.x, {POSITION_ATTRIB}.y * Uniforms.{ASPECT_RATIO_ATTRIBUTE}, {POSITION_ATTRIB}.z, 1.0) * {TRANSFORM_ATTRIB}; uvFrag = {UV_ATTRIB}; @@ -256,7 +256,7 @@ result.mesh[].renameAttribute("uv", UV_ATTRIB) result.mesh.material = TEXT_MATERIAL_TYPE.initMaterialData( name = font.name & " text", - attributes = {"fontAtlas": initDataList(@[font.fontAtlas]), "color": initDataList(@[color])}, + attributes = {"fontAtlas": InitDataList(@[font.fontAtlas]), "color": InitDataList(@[color])}, ) result.mesh.transform = transform `text=`(result, text) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/commandbuffer.nim --- a/semicongine/vulkan/commandbuffer.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/commandbuffer.nim Tue Jun 04 20:51:22 2024 +0700 @@ -28,7 +28,7 @@ commandBufferCount: uint32(nBuffers), ) result.buffers = newSeq[VkCommandBuffer](nBuffers) - checkVkResult device.vk.vkAllocateCommandBuffers(addr allocInfo, result.buffers.toCPointer) + checkVkResult device.vk.vkAllocateCommandBuffers(addr allocInfo, result.buffers.ToCPointer) proc pipelineBarrier*( commandBuffer: VkCommandBuffer, @@ -45,11 +45,11 @@ dstStageMask = dstStages.toBits, dependencyFlags = VkDependencyFlags(0), memoryBarrierCount = uint32(memoryBarriers.len), - pMemoryBarriers = memoryBarriers.toCPointer, + pMemoryBarriers = memoryBarriers.ToCPointer, bufferMemoryBarrierCount = uint32(bufferMemoryBarriers.len), - pBufferMemoryBarriers = bufferMemoryBarriers.toCPointer, + pBufferMemoryBarriers = bufferMemoryBarriers.ToCPointer, imageMemoryBarrierCount = uint32(imageBarriers.len), - pImageMemoryBarriers = imageBarriers.toCPointer, + pImageMemoryBarriers = imageBarriers.ToCPointer, ) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/descriptor.nim --- a/semicongine/vulkan/descriptor.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/descriptor.nim Tue Jun 04 20:51:22 2024 +0700 @@ -60,7 +60,7 @@ var layoutCreateInfo = VkDescriptorSetLayoutCreateInfo( sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, bindingCount: uint32(layoutbindings.len), - pBindings: layoutbindings.toCPointer + pBindings: layoutbindings.ToCPointer ) checkVkResult vkCreateDescriptorSetLayout(device.vk, addr(layoutCreateInfo), nil, addr(result.vk)) @@ -83,7 +83,7 @@ var poolInfo = VkDescriptorPoolCreateInfo( sType: VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, poolSizeCount: uint32(poolSizes.len), - pPoolSizes: poolSizes.toCPointer, + pPoolSizes: poolSizes.ToCPointer, maxSets: uint32(result.maxSets), ) checkVkResult vkCreateDescriptorPool(result.device.vk, addr(poolInfo), nil, addr(result.vk)) @@ -113,10 +113,10 @@ sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, descriptorPool: pool.vk, descriptorSetCount: uint32(layouts.len), - pSetLayouts: layouts.toCPointer, + pSetLayouts: layouts.ToCPointer, ) - checkVkResult vkAllocateDescriptorSets(pool.device.vk, addr(allocInfo), descriptorSets.toCPointer) + checkVkResult vkAllocateDescriptorSets(pool.device.vk, addr(allocInfo), descriptorSets.ToCPointer) for descriptorSet in descriptorSets: result.add DescriptorSet(vk: descriptorSet, layout: layout) @@ -168,7 +168,7 @@ dstArrayElement: 0, descriptorType: descriptor.vkType, descriptorCount: uint32(descriptor.count), - pImageInfo: imgInfos[^1].toCPointer, + pImageInfo: imgInfos[^1].ToCPointer, ) inc i - descriptorSet.layout.device.vk.vkUpdateDescriptorSets(uint32(descriptorSetWrites.len), descriptorSetWrites.toCPointer, 0, nil) + descriptorSet.layout.device.vk.vkUpdateDescriptorSets(uint32(descriptorSetWrites.len), descriptorSetWrites.ToCPointer, 0, nil) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/device.nim --- a/semicongine/vulkan/device.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/device.nim Tue Jun 04 20:51:22 2024 +0700 @@ -69,7 +69,7 @@ var createInfo = VkDeviceCreateInfo( sType: VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, queueCreateInfoCount: uint32(queueList.len), - pQueueCreateInfos: queueList.toCPointer, + pQueueCreateInfos: queueList.ToCPointer, enabledLayerCount: 0, ppEnabledLayerNames: nil, enabledExtensionCount: uint32(allExtensions.len), diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/drawable.nim --- a/semicongine/vulkan/drawable.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/drawable.nim Tue Jun 04 20:51:22 2024 +0700 @@ -40,8 +40,8 @@ commandBuffer.vkCmdBindVertexBuffers( firstBinding = 0'u32, bindingCount = uint32(buffers.len), - pBuffers = buffers.toCPointer(), - pOffsets = offsets.toCPointer() + pBuffers = buffers.ToCPointer(), + pOffsets = offsets.ToCPointer() ) if drawable.indexed: assert indexBuffer.vk.valid diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/framebuffer.nim --- a/semicongine/vulkan/framebuffer.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/framebuffer.nim Tue Jun 04 20:51:22 2024 +0700 @@ -24,7 +24,7 @@ sType: VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, renderPass: renderpass, attachmentCount: uint32(theattachments.len), - pAttachments: theattachments.toCPointer, + pAttachments: theattachments.ToCPointer, width: dimension[0], height: dimension[1], layers: 1, diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/image.nim --- a/semicongine/vulkan/image.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/image.nim Tue Jun 04 20:51:22 2024 +0700 @@ -190,7 +190,7 @@ # convert to linear space if there is not support for sRGB var data = addr image.imagedata[0] if selectedFormat in LINEAR_FORMATS: - let linearImage = image.asLinear() + let linearImage = image.AsLinear() data = addr linearImage.imagedata[0] assert size <= uint64(formatProperties.imageFormatProperties.maxResourceSize) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/instance.nim --- a/semicongine/vulkan/instance.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/instance.nim Tue Jun 04 20:51:22 2024 +0700 @@ -29,18 +29,18 @@ checkVkResult vkEnumerateInstanceExtensionProperties(nil, addr(extensionCount), nil) if extensionCount > 0: var extensions = newSeq[VkExtensionProperties](extensionCount) - checkVkResult vkEnumerateInstanceExtensionProperties(nil, addr(extensionCount), extensions.toCPointer) + checkVkResult vkEnumerateInstanceExtensionProperties(nil, addr(extensionCount), extensions.ToCPointer) for extension in extensions: - result.add(cleanString(extension.extensionName)) + result.add(CleanString(extension.extensionName)) proc getLayers*(): seq[string] = var n_layers: uint32 checkVkResult vkEnumerateInstanceLayerProperties(addr(n_layers), nil) if n_layers > 0: var layers = newSeq[VkLayerProperties](n_layers) - checkVkResult vkEnumerateInstanceLayerProperties(addr(n_layers), layers.toCPointer) + checkVkResult vkEnumerateInstanceLayerProperties(addr(n_layers), layers.ToCPointer) for layer in layers: - result.add(cleanString(layer.layerName)) + result.add(CleanString(layer.layerName)) proc createInstance*( window: NativeWindow, diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/physicaldevice.nim --- a/semicongine/vulkan/physicaldevice.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/physicaldevice.nim Tue Jun 04 20:51:22 2024 +0700 @@ -28,13 +28,13 @@ var nDevices: uint32 checkVkResult vkEnumeratePhysicalDevices(instance.vk, addr(nDevices), nil) var devices = newSeq[VkPhysicalDevice](nDevices) - checkVkResult vkEnumeratePhysicalDevices(instance.vk, addr(nDevices), devices.toCPointer) + checkVkResult vkEnumeratePhysicalDevices(instance.vk, addr(nDevices), devices.ToCPointer) for i in 0 ..< nDevices: var device = PhysicalDevice(vk: devices[i], surface: instance.surface) device.vk.vkGetPhysicalDeviceProperties(addr device.properties) device.features.stype = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 device.vk.vkGetPhysicalDeviceFeatures2(addr device.features) - device.name = device.properties.deviceName.cleanString() + device.name = device.properties.deviceName.CleanString() device.devicetype = device.properties.deviceType result.add device @@ -44,9 +44,9 @@ checkVkResult vkEnumerateDeviceExtensionProperties(device.vk, nil, addr(extensionCount), nil) if extensionCount > 0: var extensions = newSeq[VkExtensionProperties](extensionCount) - checkVkResult vkEnumerateDeviceExtensionProperties(device.vk, nil, addr(extensionCount), extensions.toCPointer) + checkVkResult vkEnumerateDeviceExtensionProperties(device.vk, nil, addr(extensionCount), extensions.ToCPointer) for extension in extensions: - result.add(cleanString(extension.extensionName)) + result.add(CleanString(extension.extensionName)) proc getSurfaceCapabilities*(device: PhysicalDevice): VkSurfaceCapabilitiesKHR = assert device.vk.valid @@ -59,7 +59,7 @@ var n_formats: uint32 checkVkResult vkGetPhysicalDeviceSurfaceFormatsKHR(device.vk, device.surface, addr(n_formats), nil) result = newSeq[VkSurfaceFormatKHR](n_formats) - checkVkResult vkGetPhysicalDeviceSurfaceFormatsKHR(device.vk, device.surface, addr(n_formats), result.toCPointer) + checkVkResult vkGetPhysicalDeviceSurfaceFormatsKHR(device.vk, device.surface, addr(n_formats), result.ToCPointer) func filterSurfaceFormat*( formats: seq[VkSurfaceFormatKHR], @@ -81,14 +81,14 @@ var n_modes: uint32 checkVkResult vkGetPhysicalDeviceSurfacePresentModesKHR(device.vk, device.surface, addr(n_modes), nil) result = newSeq[VkPresentModeKHR](n_modes) - checkVkResult vkGetPhysicalDeviceSurfacePresentModesKHR(device.vk, device.surface, addr(n_modes), result.toCPointer) + checkVkResult vkGetPhysicalDeviceSurfacePresentModesKHR(device.vk, device.surface, addr(n_modes), result.ToCPointer) proc getQueueFamilies*(device: PhysicalDevice): seq[QueueFamily] = assert device.vk.valid var nQueuefamilies: uint32 vkGetPhysicalDeviceQueueFamilyProperties(device.vk, addr nQueuefamilies, nil) var queuFamilies = newSeq[VkQueueFamilyProperties](nQueuefamilies) - vkGetPhysicalDeviceQueueFamilyProperties(device.vk, addr nQueuefamilies, queuFamilies.toCPointer) + vkGetPhysicalDeviceQueueFamilyProperties(device.vk, addr nQueuefamilies, queuFamilies.ToCPointer) for i in 0 ..< nQueuefamilies: result.add QueueFamily( device: device, diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/pipeline.nim --- a/semicongine/vulkan/pipeline.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/pipeline.nim Tue Jun 04 20:51:22 2024 +0700 @@ -70,7 +70,7 @@ thetype: Uniform, count: 1, stages: @[VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_FRAGMENT_BIT], - size: result.shaderConfiguration.uniforms.size(), + size: result.shaderConfiguration.uniforms.Size(), ) for sampler in result.shaderConfiguration.samplers: descriptors.add Descriptor( @@ -92,9 +92,9 @@ var pipelineLayoutInfo = VkPipelineLayoutCreateInfo( sType: VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, setLayoutCount: uint32(descriptorSetLayouts.len), - pSetLayouts: descriptorSetLayouts.toCPointer, + pSetLayouts: descriptorSetLayouts.ToCPointer, # pushConstantRangeCount: uint32(pushConstants.len), - # pPushConstantRanges: pushConstants.toCPointer, + # pPushConstantRanges: pushConstants.ToCPointer, ) checkVkResult vkCreatePipelineLayout(device.vk, addr(pipelineLayoutInfo), nil, addr(result.layout)) @@ -154,13 +154,13 @@ dynamicState = VkPipelineDynamicStateCreateInfo( sType: VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, dynamicStateCount: uint32(dynamicStates.len), - pDynamicStates: dynamicStates.toCPointer, + pDynamicStates: dynamicStates.ToCPointer, ) stages = @[result.shaderModules[0].getPipelineInfo(), result.shaderModules[1].getPipelineInfo()] createInfo = VkGraphicsPipelineCreateInfo( sType: VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, stageCount: uint32(stages.len), - pStages: stages.toCPointer, + pStages: stages.ToCPointer, pVertexInputState: addr(vertexInputInfo), pInputAssemblyState: addr(inputAssembly), pViewportState: addr(viewportState), diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/renderpass.nim --- a/semicongine/vulkan/renderpass.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/renderpass.nim Tue Jun 04 20:51:22 2024 +0700 @@ -60,7 +60,7 @@ inputAttachmentCount: 0, pInputAttachments: nil, colorAttachmentCount: uint32(outputs.len), - pColorAttachments: outputs.toCPointer, + pColorAttachments: outputs.ToCPointer, pResolveAttachments: nil, pDepthStencilAttachment: nil, preserveAttachmentCount: 0, @@ -71,11 +71,11 @@ var createInfo = VkRenderPassCreateInfo( sType: VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, attachmentCount: uint32(attachments.len), - pAttachments: attachments.toCPointer, + pAttachments: attachments.ToCPointer, subpassCount: uint32(subpassesList.len), - pSubpasses: subpassesList.toCPointer, + pSubpasses: subpassesList.ToCPointer, dependencyCount: uint32(dependencies.len), - pDependencies: dependencies.toCPointer, + pDependencies: dependencies.ToCPointer, ) result.device = device result.clearColor = clearColor @@ -110,7 +110,7 @@ extent: VkExtent2D(width: w, height: h), ), clearValueCount: uint32(clearColors.len), - pClearValues: clearColors.toCPointer(), + pClearValues: clearColors.ToCPointer(), ) viewport = VkViewport( x: 0.0, diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/shader.nim --- a/semicongine/vulkan/shader.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/shader.nim Tue Jun 04 20:51:22 2024 +0700 @@ -65,7 +65,7 @@ glslExe = glslExe & "." & ExeExt let command = &"{glslExe} --entry-point {entrypoint} -V --stdin -S {stagename} -o {shaderfile}" echo "run: ", command - discard staticExecChecked( + discard StaticExecChecked( command = command, input = shaderSource ) @@ -99,10 +99,10 @@ ): seq[uint32] {.compileTime.} = let code = @[&"#version {version}", "#extension GL_EXT_scalar_block_layout : require", ""] & - (if inputs.len > 0: inputs.glslInput() & @[""] else: @[]) & - (if uniforms.len > 0: uniforms.glslUniforms(binding = 0) & @[""] else: @[]) & - (if samplers.len > 0: samplers.glslSamplers(basebinding = if uniforms.len > 0: 1 else: 0) & @[""] else: @[]) & - (if outputs.len > 0: outputs.glslOutput() & @[""] else: @[]) & + (if inputs.len > 0: inputs.GlslInput() & @[""] else: @[]) & + (if uniforms.len > 0: uniforms.GlslUniforms(binding = 0) & @[""] else: @[]) & + (if samplers.len > 0: samplers.GlslSamplers(basebinding = if uniforms.len > 0: 1 else: 0) & @[""] else: @[]) & + (if outputs.len > 0: outputs.GlslOutput() & @[""] else: @[]) & @[&"void {entrypoint}(){{"] & main & @[&"}}"] @@ -187,26 +187,26 @@ for attribute in shaderConfiguration.inputs: bindings.add VkVertexInputBindingDescription( binding: binding, - stride: uint32(attribute.size), + stride: uint32(attribute.Size), inputRate: if attribute.perInstance: VK_VERTEX_INPUT_RATE_INSTANCE else: VK_VERTEX_INPUT_RATE_VERTEX, ) # allows to submit larger data structures like Mat44, for most other types will be 1 - for i in 0 ..< attribute.thetype.numberOfVertexInputAttributeDescriptors: + for i in 0 ..< attribute.thetype.NumberOfVertexInputAttributeDescriptors: attributes.add VkVertexInputAttributeDescription( binding: binding, location: location, - format: attribute.thetype.getVkFormat, - offset: uint32(i * attribute.size(perDescriptor = true)), + format: attribute.thetype.GetVkFormat, + offset: uint32(i * attribute.Size(perDescriptor = true)), ) - location += uint32(attribute.thetype.nLocationSlots) + location += uint32(attribute.thetype.NLocationSlots) inc binding return VkPipelineVertexInputStateCreateInfo( sType: VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, vertexBindingDescriptionCount: uint32(bindings.len), - pVertexBindingDescriptions: bindings.toCPointer, + pVertexBindingDescriptions: bindings.ToCPointer, vertexAttributeDescriptionCount: uint32(attributes.len), - pVertexAttributeDescriptions: attributes.toCPointer, + pVertexAttributeDescriptions: attributes.ToCPointer, ) diff -r 71315636ba82 -r a4aa9f374d44 semicongine/vulkan/swapchain.nim --- a/semicongine/vulkan/swapchain.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/semicongine/vulkan/swapchain.nim Tue Jun 04 20:51:22 2024 +0700 @@ -85,7 +85,7 @@ if device.vk.vkCreateSwapchainKHR(addr createInfo, nil, addr swapchain.vk) == VK_SUCCESS: checkVkResult device.vk.vkGetSwapchainImagesKHR(swapchain.vk, addr swapchain.nFramebuffers, nil) var framebuffers = newSeq[VkImage](swapchain.nFramebuffers) - checkVkResult device.vk.vkGetSwapchainImagesKHR(swapchain.vk, addr swapchain.nFramebuffers, framebuffers.toCPointer) + checkVkResult device.vk.vkGetSwapchainImagesKHR(swapchain.vk, addr swapchain.nFramebuffers, framebuffers.ToCPointer) for framebuffer in framebuffers: let framebufferView = VulkanImage(vk: framebuffer, format: surfaceFormat.format, device: device).createImageView() swapchain.framebufferViews.add framebufferView @@ -137,8 +137,8 @@ submitInfo = VkSubmitInfo( sType: VK_STRUCTURE_TYPE_SUBMIT_INFO, waitSemaphoreCount: 1, - pWaitSemaphores: waitSemaphores.toCPointer, - pWaitDstStageMask: waitStages.toCPointer, + pWaitSemaphores: waitSemaphores.ToCPointer, + pWaitDstStageMask: waitStages.ToCPointer, commandBufferCount: 1, pCommandBuffers: addr commandBuffer, signalSemaphoreCount: 1, diff -r 71315636ba82 -r a4aa9f374d44 tests/test_audio.nim --- a/tests/test_audio.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_audio.nim Tue Jun 04 20:51:22 2024 +0700 @@ -6,8 +6,8 @@ proc test1() = - mixer[].AddSound("test1", newSound(sineSoundData(1000, 2, 44100))) - mixer[].AddSound("test2", newSound(sineSoundData(500, 2, 44100))) + mixer[].AddSound("test1", NewSound(SineSoundData(1000, 2, 44100))) + mixer[].AddSound("test2", NewSound(SineSoundData(500, 2, 44100))) let s1 = mixer[].Play("test1", loop = true) @@ -29,19 +29,19 @@ proc test2() = let # notes - c = sineSoundData(261.6256, 0.5, 44100) - d = sineSoundData(293.6648, 0.5, 44100) - e = sineSoundData(329.6276, 0.5, 44100) - f = sineSoundData(349.2282, 0.5, 44100) - g = sineSoundData(391.9954, 0.5, 44100) - a = sineSoundData(440.0000, 0.5, 44100) - b = sineSoundData(493.8833, 0.5, 44100) - bb = sineSoundData(466.1638, 0.5, 44100) - c2 = sineSoundData(523.2511, 0.5, 44100) - d2 = sineSoundData(587.3295, 0.5, 44100) - bbShort = sineSoundData(466.1638, 0.25, 44100) - c2Short = sineSoundData(523.2511, 0.25, 44100) - d2Short = sineSoundData(587.3295, 0.25, 44100) + c = SineSoundData(261.6256, 0.5, 44100) + d = SineSoundData(293.6648, 0.5, 44100) + e = SineSoundData(329.6276, 0.5, 44100) + f = SineSoundData(349.2282, 0.5, 44100) + g = SineSoundData(391.9954, 0.5, 44100) + a = SineSoundData(440.0000, 0.5, 44100) + b = SineSoundData(493.8833, 0.5, 44100) + bb = SineSoundData(466.1638, 0.5, 44100) + c2 = SineSoundData(523.2511, 0.5, 44100) + d2 = SineSoundData(587.3295, 0.5, 44100) + bbShort = SineSoundData(466.1638, 0.25, 44100) + c2Short = SineSoundData(523.2511, 0.25, 44100) + d2Short = SineSoundData(587.3295, 0.25, 44100) # song frerejaquesData = concat( @@ -55,7 +55,7 @@ f, c, f, f, ) - mixer[].AddSound("frerejaques", newSound(frerejaquesData)) + mixer[].AddSound("frerejaques", NewSound(frerejaquesData)) discard mixer[].Play("frerejaques") while mixer[].IsPlaying(): @@ -63,7 +63,7 @@ proc test3() = mixer[].AddSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg")) - mixer[].AddSound("ping", newSound(sineSoundData(500, 0.05, 44100))) + mixer[].AddSound("ping", NewSound(SineSoundData(500, 0.05, 44100))) mixer[].AddTrack("effects") discard mixer[].Play("toccata et fugue") diff -r 71315636ba82 -r a4aa9f374d44 tests/test_collision.nim --- a/tests/test_collision.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_collision.nim Tue Jun 04 20:51:22 2024 +0700 @@ -17,13 +17,13 @@ shaderConfiguration = createShaderConfiguration( name = "default shader", inputs = [ - attr[Mat4]("transform", memoryPerformanceHint = PreferFastRead, perInstance = true), - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), - attr[Vec4f]("color", memoryPerformanceHint = PreferFastRead), + Attr[Mat4]("transform", memoryPerformanceHint = PreferFastRead, perInstance = true), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[Vec4f]("color", memoryPerformanceHint = PreferFastRead), ], - intermediates = [attr[Vec4f]("colorout")], - uniforms = [attr[Mat4]("perspective")], - outputs = [attr[Vec4f]("fragcolor")], + intermediates = [Attr[Vec4f]("colorout")], + uniforms = [Attr[Mat4]("perspective")], + outputs = [Attr[Vec4f]("fragcolor")], vertexCode = """gl_Position = vec4(position, 1.0) * (transform * Uniforms.perspective); colorout = color;""", fragmentCode = """fragcolor = colorout;""", ) diff -r 71315636ba82 -r a4aa9f374d44 tests/test_font.nim --- a/tests/test_font.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_font.nim Tue Jun 04 20:51:22 2024 +0700 @@ -34,8 +34,6 @@ while engine.UpdateInputs() and not KeyIsDown(Escape): var t = cpuTime() main_text.color = NewVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1) - if WindowWasResized(): - var winSize = engine.GetWindow().size # add character if main_text.text.len < main_text.maxLen - 1: diff -r 71315636ba82 -r a4aa9f374d44 tests/test_materials.nim --- a/tests/test_materials.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_materials.nim Tue Jun 04 20:51:22 2024 +0700 @@ -5,7 +5,7 @@ let sampler = Sampler(magnification: VK_FILTER_NEAREST, minification: VK_FILTER_NEAREST) - (RT, WT, PT) = (toRGBA("A51931").asPixel, toRGBA("F4F5F8").asPixel, toRGBA("2D2A4A").asPixel) + (RT, WT, PT) = (ToRGBA("A51931").AsPixel, ToRGBA("F4F5F8").AsPixel, ToRGBA("2D2A4A").AsPixel) thai = Image[RGBAPixel](width: 7, height: 5, imagedata: @[ RT, RT, RT, RT, RT, RT, RT, WT, WT, WT, WT, WT, WT, WT, @@ -26,8 +26,8 @@ theType = doubleTextureMaterial, name = "swiss-thai", attributes = { - "tex1": initDataList(@[Texture(colorImage: thai, sampler: sampler, isGrayscale: false)]), - "tex2": initDataList(@[Texture(colorImage: swiss, sampler: sampler, isGrayscale: false)]), + "tex1": InitDataList(@[Texture(colorImage: thai, sampler: sampler, isGrayscale: false)]), + "tex2": InitDataList(@[Texture(colorImage: swiss, sampler: sampler, isGrayscale: false)]), } ) @@ -43,18 +43,18 @@ shaderConfiguration1 = createShaderConfiguration( name = "shader 1", inputs = [ - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), - attr[Vec2f]("uv", memoryPerformanceHint = PreferFastRead), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[Vec2f]("uv", memoryPerformanceHint = PreferFastRead), ], intermediates = [ - attr[Vec2f]("uvout"), + Attr[Vec2f]("uvout"), ], - uniforms = [attr[Vec4f]("test2", arrayCount = 2)], + uniforms = [Attr[Vec4f]("test2", arrayCount = 2)], samplers = @[ - attr[Texture]("tex1"), - attr[Texture]("tex2"), + Attr[Texture]("tex1"), + Attr[Texture]("tex2"), ], - outputs = [attr[Vec4f]("color")], + outputs = [Attr[Vec4f]("color")], vertexCode = """ gl_Position = vec4(position.x, position.y + sin(Uniforms.test2[1].x) / Uniforms.test2[1].x * 0.5, position.z, 1.0); uvout = uv;""", diff -r 71315636ba82 -r a4aa9f374d44 tests/test_mesh.nim --- a/tests/test_mesh.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_mesh.nim Tue Jun 04 20:51:22 2024 +0700 @@ -21,23 +21,23 @@ shaderConfiguration = createShaderConfiguration( name = "default shader", inputs = [ - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), - attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), - attr[Vec2f]("texcoord_0", memoryPerformanceHint = PreferFastRead), - attr[Mat4]("transform", memoryPerformanceHint = PreferFastWrite, perInstance = true), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true), + Attr[Vec2f]("texcoord_0", memoryPerformanceHint = PreferFastRead), + Attr[Mat4]("transform", memoryPerformanceHint = PreferFastWrite, perInstance = true), ], intermediates = [ - attr[Vec4f]("vertexColor"), - attr[Vec2f]("colorTexCoord"), - attr[uint16]("materialIndexOut", noInterpolation = true) + Attr[Vec4f]("vertexColor"), + Attr[Vec2f]("colorTexCoord"), + Attr[uint16]("materialIndexOut", noInterpolation = true) ], - outputs = [attr[Vec4f]("color")], + outputs = [Attr[Vec4f]("color")], uniforms = [ - attr[Mat4]("projection"), - attr[Mat4]("view"), - attr[Vec4f]("color", arrayCount = 4), + Attr[Mat4]("projection"), + Attr[Mat4]("view"), + Attr[Vec4f]("color", arrayCount = 4), ], - samplers = [attr[Texture]("baseTexture", arrayCount = 4)], + samplers = [Attr[Texture]("baseTexture", arrayCount = 4)], vertexCode = &""" gl_Position = vec4(position, 1.0) * (transform * (Uniforms.view * Uniforms.projection)); vertexColor = Uniforms.color[{MATERIALINDEX_ATTRIBUTE}]; diff -r 71315636ba82 -r a4aa9f374d44 tests/test_panel.nim --- a/tests/test_panel.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_panel.nim Tue Jun 04 20:51:22 2024 +0700 @@ -33,7 +33,7 @@ origin = initPanel( transform = Scale(0.005, 0.005), color = NewVec4f(1, 1, 1, 1), - texture = Texture(isGrayscale: false, colorImage: newImage[RGBAPixel](3, 3, [T, B, T, B, B, B, T, B, T]), sampler: NEAREST_SAMPLER), + texture = Texture(isGrayscale: false, colorImage: NewImage[RGBAPixel](3, 3, [T, B, T, B, B, B, T, B, T]), sampler: NEAREST_SAMPLER), ) button = initPanel( transform = Translate(0.2, 0.1) * Scale(0.3, 0.1), diff -r 71315636ba82 -r a4aa9f374d44 tests/test_vulkan_wrapper.nim --- a/tests/test_vulkan_wrapper.nim Tue Jun 04 16:51:50 2024 +0700 +++ b/tests/test_vulkan_wrapper.nim Tue Jun 04 20:51:22 2024 +0700 @@ -23,7 +23,7 @@ mat = Mat1Type.initMaterialData( name = "mat", attributes = { - "baseTexture": initDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ + "baseTexture": InitDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ R, R, R, R, R, R, R, W, R, R, R, W, W, W, R, @@ -44,7 +44,7 @@ mat2 = Mat2Type.initMaterialData( name = "mat2", attributes = { - "baseTexture": initDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ + "baseTexture": InitDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ R, W, R, W, R, W, R, W, R, W, R, W, R, W, R, @@ -56,7 +56,7 @@ mat3 = SINGLE_COLOR_MATERIAL.initMaterialData( name = "mat3", attributes = { - "color": initDataList(@[NewVec4f(0, 1, 0, 1)]) + "color": InitDataList(@[NewVec4f(0, 1, 0, 1)]) }.toTable ) @@ -190,27 +190,27 @@ shaderConfiguration1 = createShaderConfiguration( name = "shader1", inputs = [ - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), - attr[Vec4f]("color", memoryPerformanceHint = PreferFastWrite), - attr[Mat4]("transform", perInstance = true), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[Vec4f]("color", memoryPerformanceHint = PreferFastWrite), + Attr[Mat4]("transform", perInstance = true), ], intermediates = [ - attr[Vec4f]("outcolor"), + Attr[Vec4f]("outcolor"), ], - outputs = [attr[Vec4f]("color")], - samplers = [attr[Texture]("baseTexture")], + outputs = [Attr[Vec4f]("color")], + samplers = [Attr[Texture]("baseTexture")], vertexCode = """gl_Position = vec4(position, 1.0) * transform; outcolor = color;""", fragmentCode = "color = texture(baseTexture, outcolor.xy) * 0.5 + outcolor * 0.5;", ) shaderConfiguration2 = createShaderConfiguration( name = "shader2", inputs = [ - attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), - attr[Mat4]("transform", perInstance = true), + Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), + Attr[Mat4]("transform", perInstance = true), ], - intermediates = [attr[Vec4f]("outcolor")], - outputs = [attr[Vec4f]("color")], - uniforms = [attr[Vec4f]("color", arrayCount = 1)], + intermediates = [Attr[Vec4f]("outcolor")], + outputs = [Attr[Vec4f]("color")], + uniforms = [Attr[Vec4f]("color", arrayCount = 1)], vertexCode = """gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color[0];""", fragmentCode = "color = outcolor;", )