I use table in type like:
type
RenderableObject* = object
vertices_tbl*: Table[int, seq[float32]]
indices_tbl*: Table[int, seq[uint32]]
# init
var FACE : RenderableObject
FACE.vertices_tbl = initTable[int, seq[float32]]()
FACE.indices_tbl = initTable[int, seq[uint32]]()
#init the seq
proc CreateFace(f: int, pos: int) =
if not hasKey(FACE.vertices_tbl, pos):
FACE.vertices_tbl[pos] = @[]
FACE.indices_tbl[pos] = @[]
Run
but in OpenGL function where i specify the container
proc CreateBuffers*(obj: RenderableObject) {.inline.} =
# # #
glBufferData(GL_ARRAY_BUFFER, obj.vertices_tbl[f].len*sizeof(GLfloat),
obj.vertices_tbl[f][0].unsafeAddr, GL_STATIC_DRAW)
# # #
Run
It says it cant get the address.
Is it because its not yet initialized? if I pass it with var like _obj: var
RenderableObject_ it works, but that kinda defeats the purpose and its very slow