comparison tests/test_materials.nim @ 211:744285b47a4d

did: refactor image handling
author Sam <sam@basx.dev>
date Tue, 09 May 2023 19:52:57 +0700
parents ab626e67a1ee
children 027f6ff06585
comparison
equal deleted inserted replaced
210:f3912838cd69 211:744285b47a4d
5 proc main() = 5 proc main() =
6 var scene = newScene("main", root=newEntity("rect", rect())) 6 var scene = newScene("main", root=newEntity("rect", rect()))
7 let (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8]) 7 let (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8])
8 let (RT, WT, PT) = (hexToColorAlpha("A51931").asPixel, hexToColorAlpha("F4F5F8").asPixel, hexToColorAlpha("2D2A4A").asPixel) 8 let (RT, WT, PT) = (hexToColorAlpha("A51931").asPixel, hexToColorAlpha("F4F5F8").asPixel, hexToColorAlpha("2D2A4A").asPixel)
9 let 9 let
10 t1 = TextureImage(width: 5, height: 5, imagedata: @[ 10 t1 = Image(width: 5, height: 5, imagedata: @[
11 R, R, R, R, R, 11 R, R, R, R, R,
12 R, R, W, R, R, 12 R, R, W, R, R,
13 R, W, W, W, R, 13 R, W, W, W, R,
14 R, R, W, R, R, 14 R, R, W, R, R,
15 R, R, R, R, R, 15 R, R, R, R, R,
16 ]) 16 ])
17 t2 = TextureImage(width: 7, height: 5, imagedata: @[ 17 t2 = Image(width: 7, height: 5, imagedata: @[
18 RT, RT, RT, RT, RT, RT, RT, 18 RT, RT, RT, RT, RT, RT, RT,
19 WT, WT, WT, WT, WT, WT, WT, 19 WT, WT, WT, WT, WT, WT, WT,
20 PT, PT, PT, PT, PT, PT, PT, 20 PT, PT, PT, PT, PT, PT, PT,
21 WT, WT, WT, WT, WT, WT, WT, 21 WT, WT, WT, WT, WT, WT, WT,
22 RT, RT, RT, RT, RT, RT, RT, 22 RT, RT, RT, RT, RT, RT, RT,
23 ]) 23 ])
24 scene.addTextures("my_texture", @[t1, t2]) 24 scene.addTextures("my_texture", @[t1, t2], interpolation=VK_FILTER_NEAREST)
25 scene.addShaderGlobal("time", 0'f32) 25 scene.addShaderGlobal("time", 0'f32)
26 var m: Mesh = Mesh(scene.root.components[0]) 26 var m: Mesh = Mesh(scene.root.components[0])
27 27
28 var engine = initEngine("Test materials") 28 var engine = initEngine("Test materials")
29 const 29 const