Question about arrays

Stephen Jones siwenjo at gmail.com
Sun Apr 22 15:17:10 PDT 2012


Thanks for the replies. I am still uncertain about something. The 
documentation distinguishes between dynamic slices (int[5] a = 
new int[5]) which are managed by the runtime, and stack allocated 
arrays (int[5] b). The problem I have is this. I want to be 
loading vertex positions and tex-coords of data exported from 
Blender into openGL vertex buffers. Basically the float data 
needs to be extracted from a file and passed up to the graphic 
card's memory but to do so it needs to transit through the CPU 
memory. Ideally I want to:
     a) load the data from the file into an array built upon the 
stack and owned by a function
     b) generate the vbo id and send the data off to the graphics 
card
     c) pass the id back into a class held in managed memory
     d) quit the function thus releasing the array on the stack

My confusion is, if the syntax for both stack based and managed 
memory arrays is the same (&v[0] or &v.ptr) then both must be 
objects. I guess the difference is that stack based are of 
constant length, whereas slices are dynamic because they are 
managed by the runtime.




More information about the Digitalmars-d-learn mailing list