comparison tests/test_materials.nim @ 695:d2e8b5edea7e

add: png loading with LodePNG (thanks LodePNG-author, this is a super amazing piece of code!)
author Sam <sam@basx.dev>
date Sat, 20 May 2023 16:35:23 +0700
parents 9182a5d2ea3a
children f52fccedf5ab
comparison
equal deleted inserted replaced
694:1fdcdceb13ae 695:d2e8b5edea7e
2 2
3 import semicongine 3 import semicongine
4 4
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])
8 let (RT, WT, PT) = (hexToColorAlpha("A51931").asPixel, hexToColorAlpha("F4F5F8").asPixel, hexToColorAlpha("2D2A4A").asPixel) 7 let (RT, WT, PT) = (hexToColorAlpha("A51931").asPixel, hexToColorAlpha("F4F5F8").asPixel, hexToColorAlpha("2D2A4A").asPixel)
9 let 8 let
10 t1 = Image(width: 5, height: 5, imagedata: @[ 9 t1 = Image(width: 7, height: 5, imagedata: @[
11 R, R, R, R, R,
12 R, R, W, R, R,
13 R, W, W, W, R,
14 R, R, W, R, R,
15 R, R, R, R, R,
16 ])
17 t2 = Image(width: 7, height: 5, imagedata: @[
18 RT, RT, RT, RT, RT, RT, RT, 10 RT, RT, RT, RT, RT, RT, RT,
19 WT, WT, WT, WT, WT, WT, WT, 11 WT, WT, WT, WT, WT, WT, WT,
20 PT, PT, PT, PT, PT, PT, PT, 12 PT, PT, PT, PT, PT, PT, PT,
21 WT, WT, WT, WT, WT, WT, WT, 13 WT, WT, WT, WT, WT, WT, WT,
22 RT, RT, RT, RT, RT, RT, RT, 14 RT, RT, RT, RT, RT, RT, RT,
23 ]) 15 ])
16 t2 = loadImage("flag.png")
24 scene.addTextures("my_texture", @[t1, t2], interpolation=VK_FILTER_NEAREST) 17 scene.addTextures("my_texture", @[t1, t2], interpolation=VK_FILTER_NEAREST)
25 scene.addShaderGlobalArray("test2", @[0'f32, 0'f32]) 18 scene.addShaderGlobalArray("test2", @[0'f32, 0'f32])
26 19
27 var engine = initEngine("Test materials") 20 var engine = initEngine("Test materials")
28 const 21 const