Original Post
Hi guys, need ur help again
the followign is the draw function i wrote
//draws the explosion orthogonal to the viewer
void Explosion::draw()
{
if(explosions.size()!=0)
{
tVector3 vPoint0,vPoint1,vPoint2,vPoint3;
float size=15.0f;
DWORD tickCount;
float mat[16];
glGetFloatv( GL_MODELVIEW_MATRIX, mat );
tVector3 vRight( mat[0], mat[4], mat[8] );
tVector3 vUp( mat[1], mat[5], mat[9] );
tVector3 vCenter;
glEnable(GL_BLEND);
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, render_texture);
for(int i=0;i.x);
vCenter.setY(explosions[i].y);
vCenter.setZ(explosions[i].z);
vPoint0 = vCenter + ((-vRight - vUp) * size);
vPoint1 = vCenter + (( vRight - vUp) * size);
vPoint2 = vCenter + (( vRight + vUp) * size);
vPoint3 = vCenter + ((-vRight + vUp) * size);
tickCount = GetTickCount(); // Get The Tick Count
//calculate the next frames to show
this->explosions[i].next+=(tickCount - this->explosions[i].lastTickCount); // Increase next Based On The Timer
this->explosions[i].frame=this->explosions[i].next/this->avi[this->explosions[i].exploson_number].mpf(); // Calculate The Current Frame
if (this->explosions[i].frame>=this->avi[explosions[i].exploson_number].lastframe()) // Are We At Or Past The Last Frame?
{//if the video finished playing set a flag to specify so
this->explosions[i].not_active=TRUE;
}
else
{
this->explosions[i].lastTickCount = tickCount;
//grab our next avi picture and store it in the currently binded texture
this->avi[this->explosions[i].exploson_number].GrabAVIFrame(this->explosions[i].frame);
glBegin( GL_QUADS );
glTexCoord2f(0.0f , 0.0f); glVertex3f(vPoint0.getX(),vPoint0.getY(),vPoint0.getZ());
glTexCoord2f(0.99f, 0.0f); glVertex3f(vPoint1.getX(),vPoint1.getY(),vPoint1.getZ());
glTexCoord2f(0.99f, 0.99f); glVertex3f(vPoint2.getX(),vPoint2.getY(),vPoint2.getZ());
glTexCoord2f(0.0f , 0.99f); glVertex3f(vPoint3.getX(),vPoint3.getY(),vPoint3.getZ());
glEnd();
}
}
}
}
now this works great when i just have 1 explosion of the same avi file, but when i have more than 1 explosion of the same avi array member i get lag in my program. now loading the same 2 explosions and drawing them doesnt cause lag. The lag seems to come from Grab Frame function, any ideas on how i can fix this? or what is causing the lag.