annotate src/semicongine/core/dynamic_arrays.nim @ 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 b75760e1a77b
children 857cd931d24b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
1 import ./gpu_types
206
7f921d7d0a2b did: small refactoring of module structure
Sam <sam@basx.dev>
parents: 201
diff changeset
2 import ./vector
7f921d7d0a2b did: small refactoring of module structure
Sam <sam@basx.dev>
parents: 201
diff changeset
3 import ./matrix
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
4 import ./utils
333
27aaf43e18b4 fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents: 330
diff changeset
5 import ./imagetypes
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
6
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
7 type
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
8 DataList* = object
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
9 len*: int
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
10 case theType*: DataType
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
11 of Float32: float32: ref seq[float32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
12 of Float64: float64: ref seq[float64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
13 of Int8: int8: ref seq[int8]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
14 of Int16: int16: ref seq[int16]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
15 of Int32: int32: ref seq[int32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
16 of Int64: int64: ref seq[int64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
17 of UInt8: uint8: ref seq[uint8]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
18 of UInt16: uint16: ref seq[uint16]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
19 of UInt32: uint32: ref seq[uint32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
20 of UInt64: uint64: ref seq[uint64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
21 of Vec2I32: vec2i32: ref seq[TVec2[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
22 of Vec2I64: vec2i64: ref seq[TVec2[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
23 of Vec3I32: vec3i32: ref seq[TVec3[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
24 of Vec3I64: vec3i64: ref seq[TVec3[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
25 of Vec4I32: vec4i32: ref seq[TVec4[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
26 of Vec4I64: vec4i64: ref seq[TVec4[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
27 of Vec2U32: vec2u32: ref seq[TVec2[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
28 of Vec2U64: vec2u64: ref seq[TVec2[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
29 of Vec3U32: vec3u32: ref seq[TVec3[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
30 of Vec3U64: vec3u64: ref seq[TVec3[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
31 of Vec4U32: vec4u32: ref seq[TVec4[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
32 of Vec4U64: vec4u64: ref seq[TVec4[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
33 of Vec2F32: vec2f32: ref seq[TVec2[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
34 of Vec2F64: vec2f64: ref seq[TVec2[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
35 of Vec3F32: vec3f32: ref seq[TVec3[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
36 of Vec3F64: vec3f64: ref seq[TVec3[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
37 of Vec4F32: vec4f32: ref seq[TVec4[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
38 of Vec4F64: vec4f64: ref seq[TVec4[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
39 of Mat2F32: mat2f32: ref seq[TMat2[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
40 of Mat2F64: mat2f64: ref seq[TMat2[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
41 of Mat23F32: mat23f32: ref seq[TMat23[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
42 of Mat23F64: mat23f64: ref seq[TMat23[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
43 of Mat32F32: mat32f32: ref seq[TMat32[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
44 of Mat32F64: mat32f64: ref seq[TMat32[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
45 of Mat3F32: mat3f32: ref seq[TMat3[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
46 of Mat3F64: mat3f64: ref seq[TMat3[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
47 of Mat34F32: mat34f32: ref seq[TMat34[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
48 of Mat34F64: mat34f64: ref seq[TMat34[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
49 of Mat43F32: mat43f32: ref seq[TMat43[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
50 of Mat43F64: mat43f64: ref seq[TMat43[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
51 of Mat4F32: mat4f32: ref seq[TMat4[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
52 of Mat4F64: mat4f64: ref seq[TMat4[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
53 of Sampler2D: texture: ref seq[Texture]
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
54
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
55 func size*(value: DataList): int =
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
56 value.theType.size * value.len
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
57
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
58 func `==`*(a, b: DataList): bool =
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
59 if a.theType != b.theType:
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
60 return false
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
61 case a.theType
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
62 of Float32: return a.float32 == b.float32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
63 of Float64: return a.float64 == b.float64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
64 of Int8: return a.int8 == b.int8
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
65 of Int16: return a.int16 == b.int16
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
66 of Int32: return a.int32 == b.int32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
67 of Int64: return a.int64 == b.int64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
68 of UInt8: return a.uint8 == b.uint8
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
69 of UInt16: return a.uint16 == b.uint16
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
70 of UInt32: return a.uint32 == b.uint32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
71 of UInt64: return a.uint64 == b.uint64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
72 of Vec2I32: return a.vec2i32 == b.vec2i32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
73 of Vec2I64: return a.vec2i64 == b.vec2i64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
74 of Vec3I32: return a.vec3i32 == b.vec3i32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
75 of Vec3I64: return a.vec3i64 == b.vec3i64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
76 of Vec4I32: return a.vec4i32 == b.vec4i32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
77 of Vec4I64: return a.vec4i64 == b.vec4i64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
78 of Vec2U32: return a.vec2u32 == b.vec2u32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
79 of Vec2U64: return a.vec2u64 == b.vec2u64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
80 of Vec3U32: return a.vec3u32 == b.vec3u32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
81 of Vec3U64: return a.vec3u64 == b.vec3u64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
82 of Vec4U32: return a.vec4u32 == b.vec4u32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
83 of Vec4U64: return a.vec4u64 == b.vec4u64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
84 of Vec2F32: return a.vec2f32 == b.vec2f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
85 of Vec2F64: return a.vec2f64 == b.vec2f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
86 of Vec3F32: return a.vec3f32 == b.vec3f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
87 of Vec3F64: return a.vec3f64 == b.vec3f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
88 of Vec4F32: return a.vec4f32 == b.vec4f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
89 of Vec4F64: return a.vec4f64 == b.vec4f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
90 of Mat2F32: return a.mat2f32 == b.mat2f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
91 of Mat2F64: return a.mat2f64 == b.mat2f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
92 of Mat23F32: return a.mat23f32 == b.mat23f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
93 of Mat23F64: return a.mat23f64 == b.mat23f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
94 of Mat32F32: return a.mat32f32 == b.mat32f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
95 of Mat32F64: return a.mat32f64 == b.mat32f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
96 of Mat3F32: return a.mat3f32 == b.mat3f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
97 of Mat3F64: return a.mat3f64 == b.mat3f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
98 of Mat34F32: return a.mat34f32 == b.mat34f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
99 of Mat34F64: return a.mat34f64 == b.mat34f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
100 of Mat43F32: return a.mat43f32 == b.mat43f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
101 of Mat43F64: return a.mat43f64 == b.mat43f64
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
102 of Mat4F32: return a.mat4f32 == b.mat4f32
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
103 of Mat4F64: return a.mat4f64 == b.mat4f64
333
27aaf43e18b4 fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents: 330
diff changeset
104 of Sampler2D: a.texture == b.texture
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
105
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
106 proc setValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) =
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
107 value.setLen(data.len)
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
108 when T is float32: value.float32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
109 elif T is float64: value.float64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
110 elif T is int8: value.int8[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
111 elif T is int16: value.int16[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
112 elif T is int32: value.int32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
113 elif T is int64: value.int64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
114 elif T is uint8: value.uint8[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
115 elif T is uint16: value.uint16[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
116 elif T is uint32: value.uint32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
117 elif T is uint64: value.uint64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
118 elif T is int and sizeof(int) == sizeof(int32): value.int32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
119 elif T is int and sizeof(int) == sizeof(int64): value.int64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
120 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
121 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
122 elif T is float and sizeof(float) == sizeof(float32): value.float32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
123 elif T is float and sizeof(float) == sizeof(float64): value.float64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
124 elif T is TVec2[int32]: value.vec2i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
125 elif T is TVec2[int64]: value.vec2i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
126 elif T is TVec3[int32]: value.vec3i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
127 elif T is TVec3[int64]: value.vec3i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
128 elif T is TVec4[int32]: value.vec4i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
129 elif T is TVec4[int64]: value.vec4i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
130 elif T is TVec2[uint32]: value.vec2u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
131 elif T is TVec2[uint64]: value.vec2u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
132 elif T is TVec3[uint32]: value.vec3u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
133 elif T is TVec3[uint64]: value.vec3u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
134 elif T is TVec4[uint32]: value.vec4u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
135 elif T is TVec4[uint64]: value.vec4u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
136 elif T is TVec2[float32]: value.vec2f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
137 elif T is TVec2[float64]: value.vec2f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
138 elif T is TVec3[float32]: value.vec3f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
139 elif T is TVec3[float64]: value.vec3f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
140 elif T is TVec4[float32]: value.vec4f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
141 elif T is TVec4[float64]: value.vec4f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
142 elif T is TMat2[float32]: value.mat2f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
143 elif T is TMat2[float64]: value.mat2f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
144 elif T is TMat23[float32]: value.mat23f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
145 elif T is TMat23[float64]: value.mat23f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
146 elif T is TMat32[float32]: value.mat32f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
147 elif T is TMat32[float64]: value.mat32f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
148 elif T is TMat3[float32]: value.mat3f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
149 elif T is TMat3[float64]: value.mat3f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
150 elif T is TMat34[float32]: value.mat34f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
151 elif T is TMat34[float64]: value.mat34f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
152 elif T is TMat43[float32]: value.mat43f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
153 elif T is TMat43[float64]: value.mat43f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
154 elif T is TMat4[float32]: value.mat4f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
155 elif T is TMat4[float64]: value.mat4f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
156 elif T is Texture: value.texture[] = data
225
d078b19bf531 fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents: 224
diff changeset
157 else: {. error: "Virtual datatype has no values" .}
d078b19bf531 fix: a ton of bug after refactoring gpu_data, start to add ideas for materials
Sam <sam@basx.dev>
parents: 224
diff changeset
158
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
159 func newDataList*(theType: DataType): DataList =
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
160 result = DataList(theType: theType)
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
161 case result.theType
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
162 of Float32: result.float32 = new seq[float32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
163 of Float64: result.float64 = new seq[float64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
164 of Int8: result.int8 = new seq[int8]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
165 of Int16: result.int16 = new seq[int16]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
166 of Int32: result.int32 = new seq[int32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
167 of Int64: result.int64 = new seq[int64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
168 of UInt8: result.uint8 = new seq[uint8]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
169 of UInt16: result.uint16 = new seq[uint16]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
170 of UInt32: result.uint32 = new seq[uint32]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
171 of UInt64: result.uint64 = new seq[uint64]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
172 of Vec2I32: result.vec2i32 = new seq[TVec2[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
173 of Vec2I64: result.vec2i64 = new seq[TVec2[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
174 of Vec3I32: result.vec3i32 = new seq[TVec3[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
175 of Vec3I64: result.vec3i64 = new seq[TVec3[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
176 of Vec4I32: result.vec4i32 = new seq[TVec4[int32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
177 of Vec4I64: result.vec4i64 = new seq[TVec4[int64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
178 of Vec2U32: result.vec2u32 = new seq[TVec2[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
179 of Vec2U64: result.vec2u64 = new seq[TVec2[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
180 of Vec3U32: result.vec3u32 = new seq[TVec3[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
181 of Vec3U64: result.vec3u64 = new seq[TVec3[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
182 of Vec4U32: result.vec4u32 = new seq[TVec4[uint32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
183 of Vec4U64: result.vec4u64 = new seq[TVec4[uint64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
184 of Vec2F32: result.vec2f32 = new seq[TVec2[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
185 of Vec2F64: result.vec2f64 = new seq[TVec2[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
186 of Vec3F32: result.vec3f32 = new seq[TVec3[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
187 of Vec3F64: result.vec3f64 = new seq[TVec3[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
188 of Vec4F32: result.vec4f32 = new seq[TVec4[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
189 of Vec4F64: result.vec4f64 = new seq[TVec4[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
190 of Mat2F32: result.mat2f32 = new seq[TMat2[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
191 of Mat2F64: result.mat2f64 = new seq[TMat2[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
192 of Mat23F32: result.mat23f32 = new seq[TMat23[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
193 of Mat23F64: result.mat23f64 = new seq[TMat23[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
194 of Mat32F32: result.mat32f32 = new seq[TMat32[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
195 of Mat32F64: result.mat32f64 = new seq[TMat32[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
196 of Mat3F32: result.mat3f32 = new seq[TMat3[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
197 of Mat3F64: result.mat3f64 = new seq[TMat3[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
198 of Mat34F32: result.mat34f32 = new seq[TMat34[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
199 of Mat34F64: result.mat34f64 = new seq[TMat34[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
200 of Mat43F32: result.mat43f32 = new seq[TMat43[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
201 of Mat43F64: result.mat43f64 = new seq[TMat43[float64]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
202 of Mat4F32: result.mat4f32 = new seq[TMat4[float32]]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
203 of Mat4F64: result.mat4f64 = new seq[TMat4[float64]]
343
c9b34b41a5a2 fix: error with textures as shader-globales
Sam <sam@basx.dev>
parents: 342
diff changeset
204 of Sampler2D: result.texture = new seq[Texture]
224
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
205
342
8c67f67b62fb fix: attributes with same name but different gpu memory lead to wrong results
Sam <sam@basx.dev>
parents: 340
diff changeset
206 proc newDataList*[T: GPUType](len=0): DataList =
224
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
207 result = newDataList(getDataType[T]())
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
208 if len > 0:
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
209 result.setLen(len)
224
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
210
357
2942ec187cbe allow more openArrays, better debug output, better default exports
Sam <sam@basx.dev>
parents: 350
diff changeset
211 proc newDataList*[T: GPUType](data: openArray[T]): DataList =
224
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
212 result = newDataList(getDataType[T]())
357
2942ec187cbe allow more openArrays, better debug output, better default exports
Sam <sam@basx.dev>
parents: 350
diff changeset
213 result.setValues(@data)
224
634c302869d5 did: refactor gpu data, fix some errors
Sam <sam@basx.dev>
parents: 222
diff changeset
214
342
8c67f67b62fb fix: attributes with same name but different gpu memory lead to wrong results
Sam <sam@basx.dev>
parents: 340
diff changeset
215 proc toGPUValue*[T: GPUType](value: seq[T]): DataList =
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
216 result = newDataList[T](value.len)
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
217 result.setValue(value)
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
218
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
219 func getValues*[T: GPUType|int|uint|float](value: DataList): ref seq[T] =
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
220 when T is float32: value.float32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
221 elif T is float64: value.float64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
222 elif T is int8: value.int8
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
223 elif T is int16: value.int16
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
224 elif T is int32: value.int32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
225 elif T is int64: value.int64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
226 elif T is uint8: value.uint8
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
227 elif T is uint16: value.uint16
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
228 elif T is uint32: value.uint32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
229 elif T is uint64: value.uint64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
230 elif T is int and sizeof(int) == sizeof(int32): value.int32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
231 elif T is int and sizeof(int) == sizeof(int64): value.int64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
232 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
233 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
234 elif T is float and sizeof(float) == sizeof(float32): value.float32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
235 elif T is float and sizeof(float) == sizeof(float64): value.float64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
236 elif T is TVec2[int32]: value.vec2i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
237 elif T is TVec2[int64]: value.vec2i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
238 elif T is TVec3[int32]: value.vec3i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
239 elif T is TVec3[int64]: value.vec3i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
240 elif T is TVec4[int32]: value.vec4i32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
241 elif T is TVec4[int64]: value.vec4i64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
242 elif T is TVec2[uint32]: value.vec2u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
243 elif T is TVec2[uint64]: value.vec2u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
244 elif T is TVec3[uint32]: value.vec3u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
245 elif T is TVec3[uint64]: value.vec3u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
246 elif T is TVec4[uint32]: value.vec4u32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
247 elif T is TVec4[uint64]: value.vec4u64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
248 elif T is TVec2[float32]: value.vec2f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
249 elif T is TVec2[float64]: value.vec2f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
250 elif T is TVec3[float32]: value.vec3f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
251 elif T is TVec3[float64]: value.vec3f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
252 elif T is TVec4[float32]: value.vec4f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
253 elif T is TVec4[float64]: value.vec4f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
254 elif T is TMat2[float32]: value.mat2f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
255 elif T is TMat2[float64]: value.mat2f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
256 elif T is TMat23[float32]: value.mat23f
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
257 elif T is TMat23[float64]: value.mat23f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
258 elif T is TMat32[float32]: value.mat32f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
259 elif T is TMat32[float64]: value.mat32f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
260 elif T is TMat3[float32]: value.mat3f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
261 elif T is TMat3[float64]: value.mat3f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
262 elif T is TMat34[float32]: value.mat34f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
263 elif T is TMat34[float64]: value.mat34f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
264 elif T is TMat43[float32]: value.mat43f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
265 elif T is TMat43[float64]: value.mat43f64
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
266 elif T is TMat4[float32]: value.mat4f32
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
267 elif T is TMat4[float64]: value.mat4f64
333
27aaf43e18b4 fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents: 330
diff changeset
268 elif T is Texture: value.texture
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
269 else: {. error: "Virtual datatype has no values" .}
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
270
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
271 func getValue*[T: GPUType|int|uint|float](value: DataList, i: int): T =
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
272 when T is float32: value.float32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
273 elif T is float64: value.float64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
274 elif T is int8: value.int8[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
275 elif T is int16: value.int16[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
276 elif T is int32: value.int32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
277 elif T is int64: value.int64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
278 elif T is uint8: value.uint8[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
279 elif T is uint16: value.uint16[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
280 elif T is uint32: value.uint32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
281 elif T is uint64: value.uint64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
282 elif T is int and sizeof(int) == sizeof(int32): value.int32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
283 elif T is int and sizeof(int) == sizeof(int64): value.int64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
284 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
285 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
286 elif T is float and sizeof(float) == sizeof(float32): value.float32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
287 elif T is float and sizeof(float) == sizeof(float64): value.float64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
288 elif T is TVec2[int32]: value.vec2i32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
289 elif T is TVec2[int64]: value.vec2i64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
290 elif T is TVec3[int32]: value.vec3i32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
291 elif T is TVec3[int64]: value.vec3i64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
292 elif T is TVec4[int32]: value.vec4i32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
293 elif T is TVec4[int64]: value.vec4i64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
294 elif T is TVec2[uint32]: value.vec2u32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
295 elif T is TVec2[uint64]: value.vec2u64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
296 elif T is TVec3[uint32]: value.vec3u32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
297 elif T is TVec3[uint64]: value.vec3u64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
298 elif T is TVec4[uint32]: value.vec4u32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
299 elif T is TVec4[uint64]: value.vec4u64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
300 elif T is TVec2[float32]: value.vec2f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
301 elif T is TVec2[float64]: value.vec2f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
302 elif T is TVec3[float32]: value.vec3f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
303 elif T is TVec3[float64]: value.vec3f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
304 elif T is TVec4[float32]: value.vec4f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
305 elif T is TVec4[float64]: value.vec4f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
306 elif T is TMat2[float32]: value.mat2f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
307 elif T is TMat2[float64]: value.mat2f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
308 elif T is TMat23[float32]: value.mat23f[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
309 elif T is TMat23[float64]: value.mat23f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
310 elif T is TMat32[float32]: value.mat32f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
311 elif T is TMat32[float64]: value.mat32f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
312 elif T is TMat3[float32]: value.mat3f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
313 elif T is TMat3[float64]: value.mat3f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
314 elif T is TMat34[float32]: value.mat34f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
315 elif T is TMat34[float64]: value.mat34f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
316 elif T is TMat43[float32]: value.mat43f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
317 elif T is TMat43[float64]: value.mat43f64[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
318 elif T is TMat4[float32]: value.mat4f32[i]
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
319 elif T is TMat4[float64]: value.mat4f64[i]
333
27aaf43e18b4 fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents: 330
diff changeset
320 elif T is Texture: value.texture[i]
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
321 else: {. error: "Virtual datatype has no values" .}
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
322
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
323 func getRawData*(value: var DataList): (pointer, int) =
222
ddfc54036e00 add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents: 206
diff changeset
324 if value.len == 0:
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
325 return (nil, 0)
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
326 result[1] = value.theType.size * value.len
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
327 case value.theType
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
328 of Float32: result[0] = value.float32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
329 of Float64: result[0] = value.float64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
330 of Int8: result[0] = value.int8[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
331 of Int16: result[0] = value.int16[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
332 of Int32: result[0] = value.int32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
333 of Int64: result[0] = value.int64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
334 of UInt8: result[0] = value.uint8[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
335 of UInt16: result[0] = value.uint16[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
336 of UInt32: result[0] = value.uint32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
337 of UInt64: result[0] = value.uint64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
338 of Vec2I32: result[0] = value.vec2i32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
339 of Vec2I64: result[0] = value.vec2i64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
340 of Vec3I32: result[0] = value.vec3i32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
341 of Vec3I64: result[0] = value.vec3i64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
342 of Vec4I32: result[0] = value.vec4i32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
343 of Vec4I64: result[0] = value.vec4i64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
344 of Vec2U32: result[0] = value.vec2u32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
345 of Vec2U64: result[0] = value.vec2u64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
346 of Vec3U32: result[0] = value.vec3u32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
347 of Vec3U64: result[0] = value.vec3u64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
348 of Vec4U32: result[0] = value.vec4u32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
349 of Vec4U64: result[0] = value.vec4u64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
350 of Vec2F32: result[0] = value.vec2f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
351 of Vec2F64: result[0] = value.vec2f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
352 of Vec3F32: result[0] = value.vec3f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
353 of Vec3F64: result[0] = value.vec3f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
354 of Vec4F32: result[0] = value.vec4f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
355 of Vec4F64: result[0] = value.vec4f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
356 of Mat2F32: result[0] = value.mat2f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
357 of Mat2F64: result[0] = value.mat2f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
358 of Mat23F32: result[0] = value.mat23f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
359 of Mat23F64: result[0] = value.mat23f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
360 of Mat32F32: result[0] = value.mat32f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
361 of Mat32F64: result[0] = value.mat32f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
362 of Mat3F32: result[0] = value.mat3f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
363 of Mat3F64: result[0] = value.mat3f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
364 of Mat34F32: result[0] = value.mat34f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
365 of Mat34F64: result[0] = value.mat34f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
366 of Mat43F32: result[0] = value.mat43f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
367 of Mat43F64: result[0] = value.mat43f64[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
368 of Mat4F32: result[0] = value.mat4f32[].toCPointer
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
369 of Mat4F64: result[0] = value.mat4f64[].toCPointer
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
370 of Sampler2D: result[0] = nil
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
371
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
372 proc setLen*(value: var DataList, len: int) =
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
373 value.len = len
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
374 case value.theType
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
375 of Float32: value.float32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
376 of Float64: value.float64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
377 of Int8: value.int8[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
378 of Int16: value.int16[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
379 of Int32: value.int32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
380 of Int64: value.int64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
381 of UInt8: value.uint8[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
382 of UInt16: value.uint16[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
383 of UInt32: value.uint32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
384 of UInt64: value.uint64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
385 of Vec2I32: value.vec2i32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
386 of Vec2I64: value.vec2i64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
387 of Vec3I32: value.vec3i32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
388 of Vec3I64: value.vec3i64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
389 of Vec4I32: value.vec4i32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
390 of Vec4I64: value.vec4i64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
391 of Vec2U32: value.vec2u32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
392 of Vec2U64: value.vec2u64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
393 of Vec3U32: value.vec3u32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
394 of Vec3U64: value.vec3u64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
395 of Vec4U32: value.vec4u32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
396 of Vec4U64: value.vec4u64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
397 of Vec2F32: value.vec2f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
398 of Vec2F64: value.vec2f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
399 of Vec3F32: value.vec3f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
400 of Vec3F64: value.vec3f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
401 of Vec4F32: value.vec4f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
402 of Vec4F64: value.vec4f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
403 of Mat2F32: value.mat2f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
404 of Mat2F64: value.mat2f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
405 of Mat23F32: value.mat23f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
406 of Mat23F64: value.mat23f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
407 of Mat32F32: value.mat32f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
408 of Mat32F64: value.mat32f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
409 of Mat3F32: value.mat3f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
410 of Mat3F64: value.mat3f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
411 of Mat34F32: value.mat34f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
412 of Mat34F64: value.mat34f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
413 of Mat43F32: value.mat43f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
414 of Mat43F64: value.mat43f64[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
415 of Mat4F32: value.mat4f32[].setLen(len)
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
416 of Mat4F64: value.mat4f64[].setLen(len)
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
417 of Sampler2D: discard
146
253dd797e719 add: improvments and E10 (pong)
Sam <sam@basx.dev>
parents: 137
diff changeset
418
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
419 proc appendValues*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) =
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 323
diff changeset
420 value.len += data.len
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
421 when T is float32: value.float32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
422 elif T is float64: value.float64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
423 elif T is int8: value.int8[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
424 elif T is int16: value.int16[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
425 elif T is int32: value.int32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
426 elif T is int64: value.int64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
427 elif T is uint8: value.uint8[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
428 elif T is uint16: value.uint16[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
429 elif T is uint32: value.uint32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
430 elif T is uint64: value.uint64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
431 elif T is int and sizeof(int) == sizeof(int32): value.int32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
432 elif T is int and sizeof(int) == sizeof(int64): value.int64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
433 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
434 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
435 elif T is float and sizeof(float) == sizeof(float32): value.float32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
436 elif T is float and sizeof(float) == sizeof(float64): value.float64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
437 elif T is TVec2[int32]: value.vec2i32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
438 elif T is TVec2[int64]: value.vec2i64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
439 elif T is TVec3[int32]: value.vec3i32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
440 elif T is TVec3[int64]: value.vec3i64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
441 elif T is TVec4[int32]: value.vec4i32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
442 elif T is TVec4[int64]: value.vec4i64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
443 elif T is TVec2[uint32]: value.vec2u32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
444 elif T is TVec2[uint64]: value.vec2u64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
445 elif T is TVec3[uint32]: value.vec3u32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
446 elif T is TVec3[uint64]: value.vec3u64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
447 elif T is TVec4[uint32]: value.vec4u32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
448 elif T is TVec4[uint64]: value.vec4u64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
449 elif T is TVec2[float32]: value.vec2f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
450 elif T is TVec2[float64]: value.vec2f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
451 elif T is TVec3[float32]: value.vec3f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
452 elif T is TVec3[float64]: value.vec3f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
453 elif T is TVec4[float32]: value.vec4f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
454 elif T is TVec4[float64]: value.vec4f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
455 elif T is TMat2[float32]: value.mat2f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
456 elif T is TMat2[float64]: value.mat2f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
457 elif T is TMat23[float32]: value.mat23f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
458 elif T is TMat23[float64]: value.mat23f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
459 elif T is TMat32[float32]: value.mat32f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
460 elif T is TMat32[float64]: value.mat32f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
461 elif T is TMat3[float32]: value.mat3f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
462 elif T is TMat3[float64]: value.mat3f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
463 elif T is TMat34[float32]: value.mat34f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
464 elif T is TMat34[float64]: value.mat34f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
465 elif T is TMat43[float32]: value.mat43f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
466 elif T is TMat43[float64]: value.mat43f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
467 elif T is TMat4[float32]: value.mat4f32[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
468 elif T is TMat4[float64]: value.mat4f64[].add data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
469 elif T is Texture: value.texture[].add data
222
ddfc54036e00 add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents: 206
diff changeset
470 else: {. error: "Virtual datatype has no values" .}
ddfc54036e00 add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents: 206
diff changeset
471
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
472 proc appendValues*(value: var DataList, data: DataList) =
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
473 assert value.theType == data.theType
222
ddfc54036e00 add: basic loading of glTF files (*.glb), no materials yet
Sam <sam@basx.dev>
parents: 206
diff changeset
474 value.len += data.len
329
69e18f69713b add: scene/shader compatability check, fix collision code to work with new APIs
Sam <sam@basx.dev>
parents: 326
diff changeset
475 case value.theType:
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
476 of Float32: value.float32[].add data.float32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
477 of Float64: value.float64[].add data.float64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
478 of Int8: value.int8[].add data.int8[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
479 of Int16: value.int16[].add data.int16[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
480 of Int32: value.int32[].add data.int32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
481 of Int64: value.int64[].add data.int64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
482 of UInt8: value.uint8[].add data.uint8[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
483 of UInt16: value.uint16[].add data.uint16[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
484 of UInt32: value.uint32[].add data.uint32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
485 of UInt64: value.uint64[].add data.uint64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
486 of Vec2I32: value.vec2i32[].add data.vec2i32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
487 of Vec2I64: value.vec2i64[].add data.vec2i64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
488 of Vec3I32: value.vec3i32[].add data.vec3i32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
489 of Vec3I64: value.vec3i64[].add data.vec3i64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
490 of Vec4I32: value.vec4i32[].add data.vec4i32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
491 of Vec4I64: value.vec4i64[].add data.vec4i64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
492 of Vec2U32: value.vec2u32[].add data.vec2u32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
493 of Vec2U64: value.vec2u64[].add data.vec2u64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
494 of Vec3U32: value.vec3u32[].add data.vec3u32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
495 of Vec3U64: value.vec3u64[].add data.vec3u64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
496 of Vec4U32: value.vec4u32[].add data.vec4u32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
497 of Vec4U64: value.vec4u64[].add data.vec4u64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
498 of Vec2F32: value.vec2f32[].add data.vec2f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
499 of Vec2F64: value.vec2f64[].add data.vec2f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
500 of Vec3F32: value.vec3f32[].add data.vec3f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
501 of Vec3F64: value.vec3f64[].add data.vec3f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
502 of Vec4F32: value.vec4f32[].add data.vec4f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
503 of Vec4F64: value.vec4f64[].add data.vec4f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
504 of Mat2F32: value.mat2f32[].add data.mat2f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
505 of Mat2F64: value.mat2f64[].add data.mat2f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
506 of Mat23F32: value.mat23f32[].add data.mat23f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
507 of Mat23F64: value.mat23f64[].add data.mat23f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
508 of Mat32F32: value.mat32f32[].add data.mat32f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
509 of Mat32F64: value.mat32f64[].add data.mat32f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
510 of Mat3F32: value.mat3f32[].add data.mat3f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
511 of Mat3F64: value.mat3f64[].add data.mat3f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
512 of Mat34F32: value.mat34f32[].add data.mat34f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
513 of Mat34F64: value.mat34f64[].add data.mat34f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
514 of Mat43F32: value.mat43f32[].add data.mat43f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
515 of Mat43F64: value.mat43f64[].add data.mat43f64[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
516 of Mat4F32: value.mat4f32[].add data.mat4f32[]
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
517 of Mat4F64: value.mat4f64[].add data.mat4f64[]
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
518 of Sampler2D: value.texture[].add data.texture[]
266
fd1a95f433d1 add: better material loading system, still far from great
Sam <sam@basx.dev>
parents: 231
diff changeset
519
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
520 proc setValue*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) =
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
521 when T is float32: value.float32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
522 elif T is float64: value.float64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
523 elif T is int8: value.int8[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
524 elif T is int16: value.int16[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
525 elif T is int32: value.int32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
526 elif T is int64: value.int64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
527 elif T is uint8: value.uint8[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
528 elif T is uint16: value.uint16[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
529 elif T is uint32: value.uint32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
530 elif T is uint64: value.uint64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
531 elif T is int and sizeof(int) == sizeof(int32): value.int32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
532 elif T is int and sizeof(int) == sizeof(int64): value.int64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
533 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
534 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
535 elif T is float and sizeof(float) == sizeof(float32): value.float32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
536 elif T is float and sizeof(float) == sizeof(float64): value.float64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
537 elif T is TVec2[int32]: value.vec2i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
538 elif T is TVec2[int64]: value.vec2i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
539 elif T is TVec3[int32]: value.vec3i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
540 elif T is TVec3[int64]: value.vec3i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
541 elif T is TVec4[int32]: value.vec4i32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
542 elif T is TVec4[int64]: value.vec4i64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
543 elif T is TVec2[uint32]: value.vec2u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
544 elif T is TVec2[uint64]: value.vec2u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
545 elif T is TVec3[uint32]: value.vec3u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
546 elif T is TVec3[uint64]: value.vec3u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
547 elif T is TVec4[uint32]: value.vec4u32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
548 elif T is TVec4[uint64]: value.vec4u64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
549 elif T is TVec2[float32]: value.vec2f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
550 elif T is TVec2[float64]: value.vec2f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
551 elif T is TVec3[float32]: value.vec3f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
552 elif T is TVec3[float64]: value.vec3f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
553 elif T is TVec4[float32]: value.vec4f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
554 elif T is TVec4[float64]: value.vec4f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
555 elif T is TMat2[float32]: value.mat2f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
556 elif T is TMat2[float64]: value.mat2f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
557 elif T is TMat23[float32]: value.mat23f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
558 elif T is TMat23[float64]: value.mat23f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
559 elif T is TMat32[float32]: value.mat32f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
560 elif T is TMat32[float64]: value.mat32f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
561 elif T is TMat3[float32]: value.mat3f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
562 elif T is TMat3[float64]: value.mat3f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
563 elif T is TMat34[float32]: value.mat34f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
564 elif T is TMat34[float64]: value.mat34f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
565 elif T is TMat43[float32]: value.mat43f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
566 elif T is TMat43[float64]: value.mat43f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
567 elif T is TMat4[float32]: value.mat4f32[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
568 elif T is TMat4[float64]: value.mat4f64[] = data
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
569 elif T is Texture: value.texture[] = data
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
570 else: {. error: "Virtual datatype has no values" .}
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
571
340
01ccd1393e7f did: try to reduce seq copying...
Sam <sam@basx.dev>
parents: 333
diff changeset
572 proc setValue*[T: GPUType|int|uint|float](value: var DataList, i: int, data: T) =
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
573 assert i < value.len
330
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
574 when T is float32: value.float32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
575 elif T is float64: value.float64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
576 elif T is int8: value.int8[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
577 elif T is int16: value.int16[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
578 elif T is int32: value.int32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
579 elif T is int64: value.int64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
580 elif T is uint8: value.uint8[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
581 elif T is uint16: value.uint16[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
582 elif T is uint32: value.uint32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
583 elif T is uint64: value.uint64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
584 elif T is int and sizeof(int) == sizeof(int32): value.int32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
585 elif T is int and sizeof(int) == sizeof(int64): value.int64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
586 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
587 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
588 elif T is float and sizeof(float) == sizeof(float32): value.float32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
589 elif T is float and sizeof(float) == sizeof(float64): value.float64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
590 elif T is TVec2[int32]: value.vec2i32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
591 elif T is TVec2[int64]: value.vec2i64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
592 elif T is TVec3[int32]: value.vec3i32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
593 elif T is TVec3[int64]: value.vec3i64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
594 elif T is TVec4[int32]: value.vec4i32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
595 elif T is TVec4[int64]: value.vec4i64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
596 elif T is TVec2[uint32]: value.vec2u32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
597 elif T is TVec2[uint64]: value.vec2u64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
598 elif T is TVec3[uint32]: value.vec3u32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
599 elif T is TVec3[uint64]: value.vec3u64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
600 elif T is TVec4[uint32]: value.vec4u32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
601 elif T is TVec4[uint64]: value.vec4u64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
602 elif T is TVec2[float32]: value.vec2f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
603 elif T is TVec2[float64]: value.vec2f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
604 elif T is TVec3[float32]: value.vec3f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
605 elif T is TVec3[float64]: value.vec3f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
606 elif T is TVec4[float32]: value.vec4f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
607 elif T is TVec4[float64]: value.vec4f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
608 elif T is TMat2[float32]: value.mat2f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
609 elif T is TMat2[float64]: value.mat2f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
610 elif T is TMat23[float32]: value.mat23f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
611 elif T is TMat23[float64]: value.mat23f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
612 elif T is TMat32[float32]: value.mat32f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
613 elif T is TMat32[float64]: value.mat32f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
614 elif T is TMat3[float32]: value.mat3f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
615 elif T is TMat3[float64]: value.mat3f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
616 elif T is TMat34[float32]: value.mat34f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
617 elif T is TMat34[float64]: value.mat34f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
618 elif T is TMat43[float32]: value.mat43f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
619 elif T is TMat43[float64]: value.mat43f64[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
620 elif T is TMat4[float32]: value.mat4f32[i] = data
04531bec3583 did: remove some stuff from the heap, maybe nicer?
Sam <sam@basx.dev>
parents: 329
diff changeset
621 elif T is TMat4[float64]: value.mat4f64[i] = data
333
27aaf43e18b4 fix: material handling, gltf loading, loader example
Sam <sam@basx.dev>
parents: 330
diff changeset
622 elif T is Texture: value.texture[i] = data
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 156
diff changeset
623 else: {. error: "Virtual datatype has no values" .}
123
55be3579dc30 did: refactor mesh code, prepare for instance-data
Sam <sam@basx.dev>
parents: 122
diff changeset
624
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
625 proc appendFrom*(a: var DataList, i: int, b: DataList, j: int) =
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
626 assert a.theType == b.theType
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
627 case a.theType
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
628 of Float32: a.float32[i] = b.float32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
629 of Float64: a.float64[i] = b.float64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
630 of Int8: a.int8[i] = b.int8[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
631 of Int16: a.int16[i] = b.int16[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
632 of Int32: a.int32[i] = b.int32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
633 of Int64: a.int64[i] = b.int64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
634 of UInt8: a.uint8[i] = b.uint8[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
635 of UInt16: a.uint16[i] = b.uint16[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
636 of UInt32: a.uint32[i] = b.uint32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
637 of UInt64: a.uint64[i] = b.uint64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
638 of Vec2I32: a.vec2i32[i] = b.vec2i32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
639 of Vec2I64: a.vec2i64[i] = b.vec2i64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
640 of Vec3I32: a.vec3i32[i] = b.vec3i32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
641 of Vec3I64: a.vec3i64[i] = b.vec3i64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
642 of Vec4I32: a.vec4i32[i] = b.vec4i32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
643 of Vec4I64: a.vec4i64[i] = b.vec4i64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
644 of Vec2U32: a.vec2u32[i] = b.vec2u32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
645 of Vec2U64: a.vec2u64[i] = b.vec2u64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
646 of Vec3U32: a.vec3u32[i] = b.vec3u32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
647 of Vec3U64: a.vec3u64[i] = b.vec3u64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
648 of Vec4U32: a.vec4u32[i] = b.vec4u32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
649 of Vec4U64: a.vec4u64[i] = b.vec4u64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
650 of Vec2F32: a.vec2f32[i] = b.vec2f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
651 of Vec2F64: a.vec2f64[i] = b.vec2f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
652 of Vec3F32: a.vec3f32[i] = b.vec3f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
653 of Vec3F64: a.vec3f64[i] = b.vec3f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
654 of Vec4F32: a.vec4f32[i] = b.vec4f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
655 of Vec4F64: a.vec4f64[i] = b.vec4f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
656 of Mat2F32: a.mat2f32[i] = b.mat2f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
657 of Mat2F64: a.mat2f64[i] = b.mat2f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
658 of Mat23F32: a.mat23f32[i] = b.mat23f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
659 of Mat23F64: a.mat23f64[i] = b.mat23f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
660 of Mat32F32: a.mat32f32[i] = b.mat32f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
661 of Mat32F64: a.mat32f64[i] = b.mat32f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
662 of Mat3F32: a.mat3f32[i] = b.mat3f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
663 of Mat3F64: a.mat3f64[i] = b.mat3f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
664 of Mat34F32: a.mat34f32[i] = b.mat34f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
665 of Mat34F64: a.mat34f64[i] = b.mat34f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
666 of Mat43F32: a.mat43f32[i] = b.mat43f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
667 of Mat43F64: a.mat43f64[i] = b.mat43f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
668 of Mat4F32: a.mat4f32[i] = b.mat4f32[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
669 of Mat4F64: a.mat4f64[i] = b.mat4f64[j]
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
670 of Sampler2D: a.texture[i] = b.texture[j]
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents:
diff changeset
671
347
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
672 proc copy*(datalist: DataList): DataList =
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
673 result = newDataList(datalist.theType)
5c22302f1485 add: a few API improvments, add mesh-conversion method
Sam <sam@basx.dev>
parents: 343
diff changeset
674 result.appendValues(datalist)
350
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
675
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
676 func `$`*(list: DataList): string =
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
677 case list.theType
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
678 of Float32: $list.float32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
679 of Float64: $list.float64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
680 of Int8: $list.int8[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
681 of Int16: $list.int16[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
682 of Int32: $list.int32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
683 of Int64: $list.int64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
684 of UInt8: $list.uint8[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
685 of UInt16: $list.uint16[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
686 of UInt32: $list.uint32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
687 of UInt64: $list.uint64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
688 of Vec2I32: $list.vec2i32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
689 of Vec2I64: $list.vec2i64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
690 of Vec3I32: $list.vec3i32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
691 of Vec3I64: $list.vec3i64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
692 of Vec4I32: $list.vec4i32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
693 of Vec4I64: $list.vec4i64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
694 of Vec2U32: $list.vec2u32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
695 of Vec2U64: $list.vec2u64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
696 of Vec3U32: $list.vec3u32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
697 of Vec3U64: $list.vec3u64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
698 of Vec4U32: $list.vec4u32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
699 of Vec4U64: $list.vec4u64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
700 of Vec2F32: $list.vec2f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
701 of Vec2F64: $list.vec2f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
702 of Vec3F32: $list.vec3f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
703 of Vec3F64: $list.vec3f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
704 of Vec4F32: $list.vec4f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
705 of Vec4F64: $list.vec4f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
706 of Mat2F32: $list.mat2f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
707 of Mat2F64: $list.mat2f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
708 of Mat23F32: $list.mat23f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
709 of Mat23F64: $list.mat23f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
710 of Mat32F32: $list.mat32f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
711 of Mat32F64: $list.mat32f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
712 of Mat3F32: $list.mat3f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
713 of Mat3F64: $list.mat3f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
714 of Mat34F32: $list.mat34f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
715 of Mat34F64: $list.mat34f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
716 of Mat43F32: $list.mat43f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
717 of Mat43F64: $list.mat43f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
718 of Mat4F32: $list.mat4f32[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
719 of Mat4F64: $list.mat4f64[]
b75760e1a77b did: improve error output, allow import of meshes without materials
Sam <sam@basx.dev>
parents: 347
diff changeset
720 of Sampler2D: $list.texture[]