Must use copyMem when I create and init it, Very troublesome const ATLAS_WIDTH = 128 ATLAS_HEIGHT = 128 var atlas_texture : array[ATLAS_WIDTH * ATLAS_HEIGHT, byte] let atlas_texture_src = [ # it only 128 * 120 byte 0x00.byte, 0x00, 0x22, 0x11, 0x00, 0x33, 0x11, 0x22, ... ] copyMem(atlas_texture[0].addr, atlas_texture_src[0].addr, atlas_texture_src.len) Run
Want easy init T_T like this var atlas_texture : array[ATLAS_WIDTH * ATLAS_HEIGHT, byte] = [ 0x0 ... # these val only 128 * 120, hope after val all 0x0 ] ] Run 2nd question: Some c function is void pp(const int* x) # pp( (int[]){11, 22, 33} ) Run generator nim is proc pp(x: ptr int) # if want use it must var a = [11.int,22,33] pp( cast[ptr int](a[0].addr) # I want easy, so test some type but all error pp ([11.int, 22, 33]) # proc pp(nz: openArray[int]) # proc pp(nz: UncheckedArray[int]) # proc pp(nz: array[0..0, int]) #only use them ok, but array haven't easy way to determine, must use array|seq[int], why can't use array[int] or UncheckArray[int] # proc pp(nz: array|seq[int]) # ok # now I write tempate use this func, It's ok, I think is best way template pp(nz: untyped) = let t = nz pp(cast[ptr int](t[0].addr) # but more c libs too large not suitable for manual alteration, I've use converter, but converter have bug, can't use ptr type, if have ptr myint, cant converter Run Who can tell me have a good idea? <https://github.com/Angluca/mui/blob/master/mui.nim#L287> <https://github.com/Angluca/mui/blob/master/demo/mui-sokol/main.nim#L117> <https://github.com/Angluca/mui/blob/master/demo/mui-sokol/atlas.nim#L11> I'm a newbie holp nim can directly use c code, not need c2nim convert *.c ( T_T Maybe I'm a slacker)