Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New and Delete in FB?
#1
v1c: I know allocate does that but it behaves like malloc. I'm experimenting with Vertax buffers and NEW/DELETE are better suited for them instead of malloc as I wan't to do this:


Code:
Type vertex3d
      x as glfloat
      y as glfloat
      z as glfloat
End type


Type VA
     m_nNumverts as gluint
     m_pVerts as vertex3d ptr
End type

dim vb as VA ptr

vb = Allocate(Len(vb))    'Okay

vb->m_nNumverts = 1000
I wan't to do this:

Code:
vb->m_pVerts = New vertex3d(vb->m_nNumverts)

x = vb->m_pVerts[index].x
y = vb->m_pVerts[index].y
z = vb->m_pVerts[index].z

That would be easier to read and more coder friendly ;*)



With allocate I would define VA as:


Code:
Type VA
     m_nNumverts as gluint
     m_pVerts as Glfloat ptr
End type
And :

Code:
vb->m_pVerts = Allocate(Len(vertex3d) *vb->m_nNumverts))
Then index it like

Code:
x = vb->m_pVerts[index* 3 + 0]
y = vb->m_pVerts[index* 3 + 1]
z = vb->m_pVerts[index* 3 + 2]
l337 but Cumbersome. :*(
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#2
You could use a macro with 0.12:

#define new(dtype, items) allocate( items * len( dtype ) )

If New and Del are used for OO later things would break..
Reply
#3
How would I reference it then? I'll try to DL the newest ver since I wasn't online for 5 days. :*(

Oops sorry. Seen the prob. Mistyped var. :*(
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)