i think i found a big optimization, but now im running into a different problem...
this code is crashing
Code:
glEnableClientState( GL_VERTEX_ARRAY );
// turn off writing to the depth buffer
glDepthMask( 0 );
glVertexPointer( VECTOR_SIZE, GL_FLOAT, 0, &particle_verticies[0] );
glGetFloatv( GL_MODELVIEW_MATRIX, viewMatrix );
// the up and right vectors
up_vec = Vector( viewMatrix[1], viewMatrix[5], viewMatrix[9] );
right_vec = Vector( viewMatrix[0], viewMatrix[4], viewMatrix[8] );
// topleft, topright, bottomleft, bottomright
tl_vec = up_vec - right_vec;
tr_vec = right_vec + up_vec;
bl_vec = right_vec + up_vec;
br_vec = right_vec - up_vec;
FOR( last_generated_particle )
{
if ( particles[i].life > 0 )
{
Vector loc( p.position[X], p.position[Y], p.position[Z] );
// billboarding
tl = ( loc + ( tl_vec ) * p.size );
tr = ( loc + ( tr_vec ) * p.size );
bl = ( loc + ( bl_vec ) * -p.size );
br = ( loc + ( br_vec ) * p.size );
// compiling the draw list
particle_verticies.pushBack( br.GetVerticies(), VECTOR_SIZE );
particle_verticies.pushBack( bl.GetVerticies(), VECTOR_SIZE );
particle_verticies.pushBack( tl.GetVerticies(), VECTOR_SIZE );
particle_verticies.pushBack( tr.GetVerticies(), VECTOR_SIZE );
}
}
// draw the particles
glDrawArrays( GL_QUADS, 0, particle_verticies.size() );
particle_verticies.clear();
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glDisable( GL_BLEND );
glDepthMask( 1 );
this is my entire particle render function ( well, its simplified a bit, but all the code is the same). it crashes inside of glDrawArrays(). the Vector is a 3D vector class with overloaded operators, and the particle_verticies is a custom array class, but the crash happens when i use stl vector, so thats not the problem...
if i can get this working, then i think i may have a solution to my problem.