Hi guys!
Let’s see if anyone can help me with this. I am stuck!
I am implementing Vertex and Color Arrays for my point sprite particle System. The problem lies in the glDrawArrays call (I discovered after a lot of debugging) and it returns:
“Unhandled exception in ogl_particle_system.exe:
0xC0000005: Access Violation”
However the problem only occurs if the number of particles used is big. For 30000 particles it returns the error (for 3000 particles it works fine).
I would like to fix this so that I can use big number of particles, but I don’t know what’s wrong.
My calls are:
GLsizei i=0;
while( pParticle )
{
m_PVertexArray[i].r=pParticle->m_vColor.x; //Red
m_PVertexArray[i].g=pParticle->m_vColor.y; //Green
m_PVertexArray[i].b=pParticle->m_vColor.z; //Blue
m_PVertexArray[i].a=pParticle->m_Alpha; //Alpha
m_PVertexArray[i].x=pParticle->m_vCurPos.x;
m_PVertexArray[i].y=pParticle->m_vCurPos.y;
m_PVertexArray[i].z=pParticle->m_vCurPos.z ;
i++;
pParticle = pParticle->m_pNext;
}
// enable and specify pointers to vertex arrays
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 3, //3 components per vertex (x,y,z)
GL_FLOAT,
sizeof(PointVertex),
m_PVertexArray);
glColorPointer( 4, //4 components per vertex (r,g,b,a)
GL_FLOAT,
sizeof(PointVertex),
&m_PVertexArray[0].r); //Pointer to the first color
//THE PROBLEM OCCURS DURING THE EXECUTION OF THIS LINE WHEN i IS BIG
[b] glDrawArrays(GL_POINTS, 0 //Starting at 0
, i+1); //Rendering i+1 points [/b]
glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays
glDisableClientState(GL_COLOR_ARRAY);
My point vertex structure is:
struct PointVertex
{
GLfloat x,y,z;
GLfloat r,g,b,a;
};
My Point/Vertex Array is correctly defined at the init of the program:
m_PVertexArray = new PointVertex[m_dwMaxParticles];
Where m_dwMaxParticles is the specified maximum. In the example above is 50000.
What’s going on!? Does glDrawArrays have a maximum limit for the size of the Count parameter!!!
Thanks so much in advance!!!
Cheers!
Rod