PDA

View Full Version : Freeze passing managed memory blocks to gl_Pointer



saski
07-06-2010, 11:58 PM
Hi all,

are there any restrictions of passing manual managed memory blocks along to glVertexPointer or glTexCoordPointer?

My Problem is that my system totally freezes when I try to pass vertices to the subsystem that are created with malloc(). as soon as glDrawArrays() is called there is a hard freeze.

example:

float* vtx = malloc(3*4*sizeof(float)); // 4 vertices, xyz each
// fill vertices...
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT , 0, vtx);
glDrawArrays(GL_QUADS, 0, 4);
....

above code locks up my machine. The following code however works fine:

float vtx[12]; // 4 vertices, xyz each
// fill vertices...
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT , 0, vtx);
glDrawArrays(GL_QUADS, 0, 4);
....

The only difference is the way of allocating the vertex memory. Is there any restriction, perhaps byte alignment, AMD64 compliant pointer issue or whatever? I have a AMD64 Linux system with a Geforce 9600M GT with drivers 195.xxx.

Using VBOs also solves the problem but since I have only some quads to draw I would like to keep the vertex buffer on my client side.

Any Ideas? I'm completely out of clues :(

Best
Saski