I've been slowly learning bmax and got interested in the opengl tutorials. I've progressed a bit and have decided to look at how I would store my data(vert's, UV's etc) in memory. There seems to be many different approaches from using arrays, banks or Tlist. I'd thought I would try with memalloc, here is what i have at the moment
Type baseVert
Field x:Float Ptr
Field y:Float Ptr
Field z:Float Ptr
Field VertCount:Int
Function Create:baseVert(numVerts:Int)
Local tmpVert:baseVert=New baseVert
tmpVert.x=Float Ptr(MemAlloc(NumVerts*4))
tmpVert.y=Float Ptr(MemAlloc(NumVerts*4))
tmpVert.z=Float Ptr(MemAlloc(NumVerts*4))
tmpVert.VertCount = numverts
Return tmpVert
End Function
Method Delete()
MemFree(Byte ptr(x))
MemFree(Byte ptr(y))
MemFree(Byte ptr(z))
End Method
EndType
Global a:baseVert
a=baseVert.Create(4)
a.x[0]=1.1
a.x[1]=1.2
a.x[2]=1.3
My question is, are there any pitfalls using this approach people have come across? Any suggestions on better implementation of data storage would be welcome.
|