That problem isn't related to available memory or the gpu memory.
The whole thing takes
sizeof(GLfloat) * 3 * 480000 bytes which is way more than what
you're allowed to statically allocate.
use a GLfloat pointer like this
typedef struct {
GLfloat coords[3];
} vertex_t;
GLfloat *dataPtr = malloc(mTotVertexes * vertex_t);
What you're doiing is actually allocating the thing twice. Once
statically with the declaration
GLfloat vertexes[mTotVertexex][3]; //evaluates to static allocation
of vertexes[480000][3]
this memory (if you could allocate it statically) would not be used
by the rest of your program since you are reallocating it dynamically.
Question: why the double *?
Rewrite of your code... Should work
int mTotVertexes = 480000;
GLfloat *vertexes;
glBufferData(GL_ARRAY_BUFFER, (sizeof(GLfloat) * mTotVertexes
* 3),
vertexes, GL_STATIC_DRAW);
So I have tried to calloc the array this way.
vertexes = (GLfloat *)malloc(mTotVertexes * 3 * sizeof(GLfloat));
Remember: you can use a simple vector (1d) to store objects
(vertexes) with more than one coordinate.
To iterate through the vector and set/get axis coordinates
for(i=0;i<mTotVertexes;i+=3) {
x = vertexes[+0];
y = vertexes[i+1];
z = vertexes[i+2];
}
And finally (THIS IS REALLY IMPORTANT): Do not ever do this
vertexes[i] = (GLfloat*)calloc(3, sizeof(GLfloat));
don't ever iterate through an array and allocate memory for each
item. If you want to do this, you might as well use a linked list.
The whole purpose of using arrays/vbos is to get a continuous
sector in memory which can be easily copied back and forth with a
single memcpy. By dynamically allocating EACH vertex's coordinates,
you're incresing the probabilities of NOT having your data in a
continuous block. The end result is a delay between reads/writes of
each vertex while the gpu uses dma to search the address of the
vertex before copy ( i think).
Cheers,
Filipe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden