Mercurial > games > semicongine
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 |
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 | 6 |
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 | 11 of Float32: float32: ref seq[float32] |
12 of Float64: float64: ref seq[float64] | |
13 of Int8: int8: ref seq[int8] | |
14 of Int16: int16: ref seq[int16] | |
15 of Int32: int32: ref seq[int32] | |
16 of Int64: int64: ref seq[int64] | |
17 of UInt8: uint8: ref seq[uint8] | |
18 of UInt16: uint16: ref seq[uint16] | |
19 of UInt32: uint32: ref seq[uint32] | |
20 of UInt64: uint64: ref seq[uint64] | |
21 of Vec2I32: vec2i32: ref seq[TVec2[int32]] | |
22 of Vec2I64: vec2i64: ref seq[TVec2[int64]] | |
23 of Vec3I32: vec3i32: ref seq[TVec3[int32]] | |
24 of Vec3I64: vec3i64: ref seq[TVec3[int64]] | |
25 of Vec4I32: vec4i32: ref seq[TVec4[int32]] | |
26 of Vec4I64: vec4i64: ref seq[TVec4[int64]] | |
27 of Vec2U32: vec2u32: ref seq[TVec2[uint32]] | |
28 of Vec2U64: vec2u64: ref seq[TVec2[uint64]] | |
29 of Vec3U32: vec3u32: ref seq[TVec3[uint32]] | |
30 of Vec3U64: vec3u64: ref seq[TVec3[uint64]] | |
31 of Vec4U32: vec4u32: ref seq[TVec4[uint32]] | |
32 of Vec4U64: vec4u64: ref seq[TVec4[uint64]] | |
33 of Vec2F32: vec2f32: ref seq[TVec2[float32]] | |
34 of Vec2F64: vec2f64: ref seq[TVec2[float64]] | |
35 of Vec3F32: vec3f32: ref seq[TVec3[float32]] | |
36 of Vec3F64: vec3f64: ref seq[TVec3[float64]] | |
37 of Vec4F32: vec4f32: ref seq[TVec4[float32]] | |
38 of Vec4F64: vec4f64: ref seq[TVec4[float64]] | |
39 of Mat2F32: mat2f32: ref seq[TMat2[float32]] | |
40 of Mat2F64: mat2f64: ref seq[TMat2[float64]] | |
41 of Mat23F32: mat23f32: ref seq[TMat23[float32]] | |
42 of Mat23F64: mat23f64: ref seq[TMat23[float64]] | |
43 of Mat32F32: mat32f32: ref seq[TMat32[float32]] | |
44 of Mat32F64: mat32f64: ref seq[TMat32[float64]] | |
45 of Mat3F32: mat3f32: ref seq[TMat3[float32]] | |
46 of Mat3F64: mat3f64: ref seq[TMat3[float64]] | |
47 of Mat34F32: mat34f32: ref seq[TMat34[float32]] | |
48 of Mat34F64: mat34f64: ref seq[TMat34[float64]] | |
49 of Mat43F32: mat43f32: ref seq[TMat43[float32]] | |
50 of Mat43F64: mat43f64: ref seq[TMat43[float64]] | |
51 of Mat4F32: mat4f32: ref seq[TMat4[float32]] | |
52 of Mat4F64: mat4f64: ref seq[TMat4[float64]] | |
53 of Sampler2D: texture: ref seq[Texture] | |
111 | 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 | 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 | 108 when T is float32: value.float32[] = data |
109 elif T is float64: value.float64[] = data | |
110 elif T is int8: value.int8[] = data | |
111 elif T is int16: value.int16[] = data | |
112 elif T is int32: value.int32[] = data | |
113 elif T is int64: value.int64[] = data | |
114 elif T is uint8: value.uint8[] = data | |
115 elif T is uint16: value.uint16[] = data | |
116 elif T is uint32: value.uint32[] = data | |
117 elif T is uint64: value.uint64[] = data | |
118 elif T is int and sizeof(int) == sizeof(int32): value.int32[] = data | |
119 elif T is int and sizeof(int) == sizeof(int64): value.int64[] = data | |
120 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[] = data | |
121 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[] = data | |
122 elif T is float and sizeof(float) == sizeof(float32): value.float32[] = data | |
123 elif T is float and sizeof(float) == sizeof(float64): value.float64[] = data | |
124 elif T is TVec2[int32]: value.vec2i32[] = data | |
125 elif T is TVec2[int64]: value.vec2i64[] = data | |
126 elif T is TVec3[int32]: value.vec3i32[] = data | |
127 elif T is TVec3[int64]: value.vec3i64[] = data | |
128 elif T is TVec4[int32]: value.vec4i32[] = data | |
129 elif T is TVec4[int64]: value.vec4i64[] = data | |
130 elif T is TVec2[uint32]: value.vec2u32[] = data | |
131 elif T is TVec2[uint64]: value.vec2u64[] = data | |
132 elif T is TVec3[uint32]: value.vec3u32[] = data | |
133 elif T is TVec3[uint64]: value.vec3u64[] = data | |
134 elif T is TVec4[uint32]: value.vec4u32[] = data | |
135 elif T is TVec4[uint64]: value.vec4u64[] = data | |
136 elif T is TVec2[float32]: value.vec2f32[] = data | |
137 elif T is TVec2[float64]: value.vec2f64[] = data | |
138 elif T is TVec3[float32]: value.vec3f32[] = data | |
139 elif T is TVec3[float64]: value.vec3f64[] = data | |
140 elif T is TVec4[float32]: value.vec4f32[] = data | |
141 elif T is TVec4[float64]: value.vec4f64[] = data | |
142 elif T is TMat2[float32]: value.mat2f32[] = data | |
143 elif T is TMat2[float64]: value.mat2f64[] = data | |
144 elif T is TMat23[float32]: value.mat23f32[] = data | |
145 elif T is TMat23[float64]: value.mat23f64[] = data | |
146 elif T is TMat32[float32]: value.mat32f32[] = data | |
147 elif T is TMat32[float64]: value.mat32f64[] = data | |
148 elif T is TMat3[float32]: value.mat3f32[] = data | |
149 elif T is TMat3[float64]: value.mat3f64[] = data | |
150 elif T is TMat34[float32]: value.mat34f32[] = data | |
151 elif T is TMat34[float64]: value.mat34f64[] = data | |
152 elif T is TMat43[float32]: value.mat43f32[] = data | |
153 elif T is TMat43[float64]: value.mat43f64[] = data | |
154 elif T is TMat4[float32]: value.mat4f32[] = data | |
155 elif T is TMat4[float64]: value.mat4f64[] = data | |
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 | 162 of Float32: result.float32 = new seq[float32] |
163 of Float64: result.float64 = new seq[float64] | |
164 of Int8: result.int8 = new seq[int8] | |
165 of Int16: result.int16 = new seq[int16] | |
166 of Int32: result.int32 = new seq[int32] | |
167 of Int64: result.int64 = new seq[int64] | |
168 of UInt8: result.uint8 = new seq[uint8] | |
169 of UInt16: result.uint16 = new seq[uint16] | |
170 of UInt32: result.uint32 = new seq[uint32] | |
171 of UInt64: result.uint64 = new seq[uint64] | |
172 of Vec2I32: result.vec2i32 = new seq[TVec2[int32]] | |
173 of Vec2I64: result.vec2i64 = new seq[TVec2[int64]] | |
174 of Vec3I32: result.vec3i32 = new seq[TVec3[int32]] | |
175 of Vec3I64: result.vec3i64 = new seq[TVec3[int64]] | |
176 of Vec4I32: result.vec4i32 = new seq[TVec4[int32]] | |
177 of Vec4I64: result.vec4i64 = new seq[TVec4[int64]] | |
178 of Vec2U32: result.vec2u32 = new seq[TVec2[uint32]] | |
179 of Vec2U64: result.vec2u64 = new seq[TVec2[uint64]] | |
180 of Vec3U32: result.vec3u32 = new seq[TVec3[uint32]] | |
181 of Vec3U64: result.vec3u64 = new seq[TVec3[uint64]] | |
182 of Vec4U32: result.vec4u32 = new seq[TVec4[uint32]] | |
183 of Vec4U64: result.vec4u64 = new seq[TVec4[uint64]] | |
184 of Vec2F32: result.vec2f32 = new seq[TVec2[float32]] | |
185 of Vec2F64: result.vec2f64 = new seq[TVec2[float64]] | |
186 of Vec3F32: result.vec3f32 = new seq[TVec3[float32]] | |
187 of Vec3F64: result.vec3f64 = new seq[TVec3[float64]] | |
188 of Vec4F32: result.vec4f32 = new seq[TVec4[float32]] | |
189 of Vec4F64: result.vec4f64 = new seq[TVec4[float64]] | |
190 of Mat2F32: result.mat2f32 = new seq[TMat2[float32]] | |
191 of Mat2F64: result.mat2f64 = new seq[TMat2[float64]] | |
192 of Mat23F32: result.mat23f32 = new seq[TMat23[float32]] | |
193 of Mat23F64: result.mat23f64 = new seq[TMat23[float64]] | |
194 of Mat32F32: result.mat32f32 = new seq[TMat32[float32]] | |
195 of Mat32F64: result.mat32f64 = new seq[TMat32[float64]] | |
196 of Mat3F32: result.mat3f32 = new seq[TMat3[float32]] | |
197 of Mat3F64: result.mat3f64 = new seq[TMat3[float64]] | |
198 of Mat34F32: result.mat34f32 = new seq[TMat34[float32]] | |
199 of Mat34F64: result.mat34f64 = new seq[TMat34[float64]] | |
200 of Mat43F32: result.mat43f32 = new seq[TMat43[float32]] | |
201 of Mat43F64: result.mat43f64 = new seq[TMat43[float64]] | |
202 of Mat4F32: result.mat4f32 = new seq[TMat4[float32]] | |
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 | 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 | 207 result = newDataList(getDataType[T]()) |
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 | 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 | 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 | 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 | 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 | 328 of Float32: result[0] = value.float32[].toCPointer |
329 of Float64: result[0] = value.float64[].toCPointer | |
330 of Int8: result[0] = value.int8[].toCPointer | |
331 of Int16: result[0] = value.int16[].toCPointer | |
332 of Int32: result[0] = value.int32[].toCPointer | |
333 of Int64: result[0] = value.int64[].toCPointer | |
334 of UInt8: result[0] = value.uint8[].toCPointer | |
335 of UInt16: result[0] = value.uint16[].toCPointer | |
336 of UInt32: result[0] = value.uint32[].toCPointer | |
337 of UInt64: result[0] = value.uint64[].toCPointer | |
338 of Vec2I32: result[0] = value.vec2i32[].toCPointer | |
339 of Vec2I64: result[0] = value.vec2i64[].toCPointer | |
340 of Vec3I32: result[0] = value.vec3i32[].toCPointer | |
341 of Vec3I64: result[0] = value.vec3i64[].toCPointer | |
342 of Vec4I32: result[0] = value.vec4i32[].toCPointer | |
343 of Vec4I64: result[0] = value.vec4i64[].toCPointer | |
344 of Vec2U32: result[0] = value.vec2u32[].toCPointer | |
345 of Vec2U64: result[0] = value.vec2u64[].toCPointer | |
346 of Vec3U32: result[0] = value.vec3u32[].toCPointer | |
347 of Vec3U64: result[0] = value.vec3u64[].toCPointer | |
348 of Vec4U32: result[0] = value.vec4u32[].toCPointer | |
349 of Vec4U64: result[0] = value.vec4u64[].toCPointer | |
350 of Vec2F32: result[0] = value.vec2f32[].toCPointer | |
351 of Vec2F64: result[0] = value.vec2f64[].toCPointer | |
352 of Vec3F32: result[0] = value.vec3f32[].toCPointer | |
353 of Vec3F64: result[0] = value.vec3f64[].toCPointer | |
354 of Vec4F32: result[0] = value.vec4f32[].toCPointer | |
355 of Vec4F64: result[0] = value.vec4f64[].toCPointer | |
356 of Mat2F32: result[0] = value.mat2f32[].toCPointer | |
357 of Mat2F64: result[0] = value.mat2f64[].toCPointer | |
358 of Mat23F32: result[0] = value.mat23f32[].toCPointer | |
359 of Mat23F64: result[0] = value.mat23f64[].toCPointer | |
360 of Mat32F32: result[0] = value.mat32f32[].toCPointer | |
361 of Mat32F64: result[0] = value.mat32f64[].toCPointer | |
362 of Mat3F32: result[0] = value.mat3f32[].toCPointer | |
363 of Mat3F64: result[0] = value.mat3f64[].toCPointer | |
364 of Mat34F32: result[0] = value.mat34f32[].toCPointer | |
365 of Mat34F64: result[0] = value.mat34f64[].toCPointer | |
366 of Mat43F32: result[0] = value.mat43f32[].toCPointer | |
367 of Mat43F64: result[0] = value.mat43f64[].toCPointer | |
368 of Mat4F32: result[0] = value.mat4f32[].toCPointer | |
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 | 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 | 375 of Float32: value.float32[].setLen(len) |
376 of Float64: value.float64[].setLen(len) | |
377 of Int8: value.int8[].setLen(len) | |
378 of Int16: value.int16[].setLen(len) | |
379 of Int32: value.int32[].setLen(len) | |
380 of Int64: value.int64[].setLen(len) | |
381 of UInt8: value.uint8[].setLen(len) | |
382 of UInt16: value.uint16[].setLen(len) | |
383 of UInt32: value.uint32[].setLen(len) | |
384 of UInt64: value.uint64[].setLen(len) | |
385 of Vec2I32: value.vec2i32[].setLen(len) | |
386 of Vec2I64: value.vec2i64[].setLen(len) | |
387 of Vec3I32: value.vec3i32[].setLen(len) | |
388 of Vec3I64: value.vec3i64[].setLen(len) | |
389 of Vec4I32: value.vec4i32[].setLen(len) | |
390 of Vec4I64: value.vec4i64[].setLen(len) | |
391 of Vec2U32: value.vec2u32[].setLen(len) | |
392 of Vec2U64: value.vec2u64[].setLen(len) | |
393 of Vec3U32: value.vec3u32[].setLen(len) | |
394 of Vec3U64: value.vec3u64[].setLen(len) | |
395 of Vec4U32: value.vec4u32[].setLen(len) | |
396 of Vec4U64: value.vec4u64[].setLen(len) | |
397 of Vec2F32: value.vec2f32[].setLen(len) | |
398 of Vec2F64: value.vec2f64[].setLen(len) | |
399 of Vec3F32: value.vec3f32[].setLen(len) | |
400 of Vec3F64: value.vec3f64[].setLen(len) | |
401 of Vec4F32: value.vec4f32[].setLen(len) | |
402 of Vec4F64: value.vec4f64[].setLen(len) | |
403 of Mat2F32: value.mat2f32[].setLen(len) | |
404 of Mat2F64: value.mat2f64[].setLen(len) | |
405 of Mat23F32: value.mat23f32[].setLen(len) | |
406 of Mat23F64: value.mat23f64[].setLen(len) | |
407 of Mat32F32: value.mat32f32[].setLen(len) | |
408 of Mat32F64: value.mat32f64[].setLen(len) | |
409 of Mat3F32: value.mat3f32[].setLen(len) | |
410 of Mat3F64: value.mat3f64[].setLen(len) | |
411 of Mat34F32: value.mat34f32[].setLen(len) | |
412 of Mat34F64: value.mat34f64[].setLen(len) | |
413 of Mat43F32: value.mat43f32[].setLen(len) | |
414 of Mat43F64: value.mat43f64[].setLen(len) | |
415 of Mat4F32: value.mat4f32[].setLen(len) | |
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 | 418 |
340 | 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 | 421 when T is float32: value.float32[].add data |
422 elif T is float64: value.float64[].add data | |
423 elif T is int8: value.int8[].add data | |
424 elif T is int16: value.int16[].add data | |
425 elif T is int32: value.int32[].add data | |
426 elif T is int64: value.int64[].add data | |
427 elif T is uint8: value.uint8[].add data | |
428 elif T is uint16: value.uint16[].add data | |
429 elif T is uint32: value.uint32[].add data | |
430 elif T is uint64: value.uint64[].add data | |
431 elif T is int and sizeof(int) == sizeof(int32): value.int32[].add data | |
432 elif T is int and sizeof(int) == sizeof(int64): value.int64[].add data | |
433 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[].add data | |
434 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[].add data | |
435 elif T is float and sizeof(float) == sizeof(float32): value.float32[].add data | |
436 elif T is float and sizeof(float) == sizeof(float64): value.float64[].add data | |
437 elif T is TVec2[int32]: value.vec2i32[].add data | |
438 elif T is TVec2[int64]: value.vec2i64[].add data | |
439 elif T is TVec3[int32]: value.vec3i32[].add data | |
440 elif T is TVec3[int64]: value.vec3i64[].add data | |
441 elif T is TVec4[int32]: value.vec4i32[].add data | |
442 elif T is TVec4[int64]: value.vec4i64[].add data | |
443 elif T is TVec2[uint32]: value.vec2u32[].add data | |
444 elif T is TVec2[uint64]: value.vec2u64[].add data | |
445 elif T is TVec3[uint32]: value.vec3u32[].add data | |
446 elif T is TVec3[uint64]: value.vec3u64[].add data | |
447 elif T is TVec4[uint32]: value.vec4u32[].add data | |
448 elif T is TVec4[uint64]: value.vec4u64[].add data | |
449 elif T is TVec2[float32]: value.vec2f32[].add data | |
450 elif T is TVec2[float64]: value.vec2f64[].add data | |
451 elif T is TVec3[float32]: value.vec3f32[].add data | |
452 elif T is TVec3[float64]: value.vec3f64[].add data | |
453 elif T is TVec4[float32]: value.vec4f32[].add data | |
454 elif T is TVec4[float64]: value.vec4f64[].add data | |
455 elif T is TMat2[float32]: value.mat2f32[].add data | |
456 elif T is TMat2[float64]: value.mat2f64[].add data | |
457 elif T is TMat23[float32]: value.mat23f32[].add data | |
458 elif T is TMat23[float64]: value.mat23f64[].add data | |
459 elif T is TMat32[float32]: value.mat32f32[].add data | |
460 elif T is TMat32[float64]: value.mat32f64[].add data | |
461 elif T is TMat3[float32]: value.mat3f32[].add data | |
462 elif T is TMat3[float64]: value.mat3f64[].add data | |
463 elif T is TMat34[float32]: value.mat34f32[].add data | |
464 elif T is TMat34[float64]: value.mat34f64[].add data | |
465 elif T is TMat43[float32]: value.mat43f32[].add data | |
466 elif T is TMat43[float64]: value.mat43f64[].add data | |
467 elif T is TMat4[float32]: value.mat4f32[].add data | |
468 elif T is TMat4[float64]: value.mat4f64[].add data | |
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 | 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 | 476 of Float32: value.float32[].add data.float32[] |
477 of Float64: value.float64[].add data.float64[] | |
478 of Int8: value.int8[].add data.int8[] | |
479 of Int16: value.int16[].add data.int16[] | |
480 of Int32: value.int32[].add data.int32[] | |
481 of Int64: value.int64[].add data.int64[] | |
482 of UInt8: value.uint8[].add data.uint8[] | |
483 of UInt16: value.uint16[].add data.uint16[] | |
484 of UInt32: value.uint32[].add data.uint32[] | |
485 of UInt64: value.uint64[].add data.uint64[] | |
486 of Vec2I32: value.vec2i32[].add data.vec2i32[] | |
487 of Vec2I64: value.vec2i64[].add data.vec2i64[] | |
488 of Vec3I32: value.vec3i32[].add data.vec3i32[] | |
489 of Vec3I64: value.vec3i64[].add data.vec3i64[] | |
490 of Vec4I32: value.vec4i32[].add data.vec4i32[] | |
491 of Vec4I64: value.vec4i64[].add data.vec4i64[] | |
492 of Vec2U32: value.vec2u32[].add data.vec2u32[] | |
493 of Vec2U64: value.vec2u64[].add data.vec2u64[] | |
494 of Vec3U32: value.vec3u32[].add data.vec3u32[] | |
495 of Vec3U64: value.vec3u64[].add data.vec3u64[] | |
496 of Vec4U32: value.vec4u32[].add data.vec4u32[] | |
497 of Vec4U64: value.vec4u64[].add data.vec4u64[] | |
498 of Vec2F32: value.vec2f32[].add data.vec2f32[] | |
499 of Vec2F64: value.vec2f64[].add data.vec2f64[] | |
500 of Vec3F32: value.vec3f32[].add data.vec3f32[] | |
501 of Vec3F64: value.vec3f64[].add data.vec3f64[] | |
502 of Vec4F32: value.vec4f32[].add data.vec4f32[] | |
503 of Vec4F64: value.vec4f64[].add data.vec4f64[] | |
504 of Mat2F32: value.mat2f32[].add data.mat2f32[] | |
505 of Mat2F64: value.mat2f64[].add data.mat2f64[] | |
506 of Mat23F32: value.mat23f32[].add data.mat23f32[] | |
507 of Mat23F64: value.mat23f64[].add data.mat23f64[] | |
508 of Mat32F32: value.mat32f32[].add data.mat32f32[] | |
509 of Mat32F64: value.mat32f64[].add data.mat32f64[] | |
510 of Mat3F32: value.mat3f32[].add data.mat3f32[] | |
511 of Mat3F64: value.mat3f64[].add data.mat3f64[] | |
512 of Mat34F32: value.mat34f32[].add data.mat34f32[] | |
513 of Mat34F64: value.mat34f64[].add data.mat34f64[] | |
514 of Mat43F32: value.mat43f32[].add data.mat43f32[] | |
515 of Mat43F64: value.mat43f64[].add data.mat43f64[] | |
516 of Mat4F32: value.mat4f32[].add data.mat4f32[] | |
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 | 520 proc setValue*[T: GPUType|int|uint|float](value: var DataList, data: seq[T]) = |
521 when T is float32: value.float32[] = data | |
522 elif T is float64: value.float64[] = data | |
523 elif T is int8: value.int8[] = data | |
524 elif T is int16: value.int16[] = data | |
525 elif T is int32: value.int32[] = data | |
526 elif T is int64: value.int64[] = data | |
527 elif T is uint8: value.uint8[] = data | |
528 elif T is uint16: value.uint16[] = data | |
529 elif T is uint32: value.uint32[] = data | |
530 elif T is uint64: value.uint64[] = data | |
531 elif T is int and sizeof(int) == sizeof(int32): value.int32[] = data | |
532 elif T is int and sizeof(int) == sizeof(int64): value.int64[] = data | |
533 elif T is uint and sizeof(uint) == sizeof(uint32): value.uint32[] = data | |
534 elif T is uint and sizeof(uint) == sizeof(uint64): value.uint64[] = data | |
535 elif T is float and sizeof(float) == sizeof(float32): value.float32[] = data | |
536 elif T is float and sizeof(float) == sizeof(float64): value.float64[] = data | |
537 elif T is TVec2[int32]: value.vec2i32[] = data | |
538 elif T is TVec2[int64]: value.vec2i64[] = data | |
539 elif T is TVec3[int32]: value.vec3i32[] = data | |
540 elif T is TVec3[int64]: value.vec3i64[] = data | |
541 elif T is TVec4[int32]: value.vec4i32[] = data | |
542 elif T is TVec4[int64]: value.vec4i64[] = data | |
543 elif T is TVec2[uint32]: value.vec2u32[] = data | |
544 elif T is TVec2[uint64]: value.vec2u64[] = data | |
545 elif T is TVec3[uint32]: value.vec3u32[] = data | |
546 elif T is TVec3[uint64]: value.vec3u64[] = data | |
547 elif T is TVec4[uint32]: value.vec4u32[] = data | |
548 elif T is TVec4[uint64]: value.vec4u64[] = data | |
549 elif T is TVec2[float32]: value.vec2f32[] = data | |
550 elif T is TVec2[float64]: value.vec2f64[] = data | |
551 elif T is TVec3[float32]: value.vec3f32[] = data | |
552 elif T is TVec3[float64]: value.vec3f64[] = data | |
553 elif T is TVec4[float32]: value.vec4f32[] = data | |
554 elif T is TVec4[float64]: value.vec4f64[] = data | |
555 elif T is TMat2[float32]: value.mat2f32[] = data | |
556 elif T is TMat2[float64]: value.mat2f64[] = data | |
557 elif T is TMat23[float32]: value.mat23f32[] = data | |
558 elif T is TMat23[float64]: value.mat23f64[] = data | |
559 elif T is TMat32[float32]: value.mat32f32[] = data | |
560 elif T is TMat32[float64]: value.mat32f64[] = data | |
561 elif T is TMat3[float32]: value.mat3f32[] = data | |
562 elif T is TMat3[float64]: value.mat3f64[] = data | |
563 elif T is TMat34[float32]: value.mat34f32[] = data | |
564 elif T is TMat34[float64]: value.mat34f64[] = data | |
565 elif T is TMat43[float32]: value.mat43f32[] = data | |
566 elif T is TMat43[float64]: value.mat43f64[] = data | |
567 elif T is TMat4[float32]: value.mat4f32[] = data | |
568 elif T is TMat4[float64]: value.mat4f64[] = data | |
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 | 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 | 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[] |