Hi,
I am making a game with couple of level. each level is represented in terms of states, like we can push and pop each state.
Each level have common functions like
Initialise()->HandleEvents->Update()->Draw()
In one level i am having couple of sprite and I am using sfml functions like Sprite->Move(x,y) etc to manipulate the entities.
In this level i tried to call function from my particle engine. In the particle engine i have tried to display the particle using opengl primitives. It will look like
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
std::list<Particle>::iterator iter;
for( iter = mL_Particle.begin(); iter != mL_Particle.end(); ++iter)
{
if((iter)->m_Energy > 0)
{
//if the particle is still alive, then draw
glPushMatrix();
glTranslatef((iter)->m_ParticlePosition.x, (iter)->m_ParticlePosition.y, -400.0f);
std::cout<<(iter)->m_ParticlePosition.y<<std::endl;
glRotatef((iter)->m_Angle,0,0,1);
//glScalef(1.0f, 1.0f, 1.0f);
glColor4ub((iter)->m_Color.r, (iter)->m_Color.g, (iter)->m_Color.b, (iter)->m_Color.a);
glBegin(GL_QUADS);
glTexCoord2f(texCoords.Left, texCoords.Top); glVertex2f(-halfWidth, -halfHeight);
glTexCoord2f(texCoords.Left, texCoords.Bottom); glVertex2f(-halfWidth, halfHeight);
glTexCoord2f(texCoords.Right, texCoords.Bottom); glVertex2f(halfWidth, halfHeight);
glTexCoord2f(texCoords.Right, texCoords.Top); glVertex2f(halfWidth, -halfHeight);
glEnd();
glColor4ub(255, 255, 255, 255);
glPopMatrix();
}
}
Couple of problem is happening:
1) The positioning of the particle is not correct.Since in the particle case its using the Opengl co-ordinate with origin at centre of the screen.
2) It gets slow and frame rate decreases ..I dont know why this is happening...Is it because i am using one draw() for smfl related case and another draw() is getting called for Opengl.
?
Everything runs smooth and when i click a button to generate a particle effect it get slower and slower!!!!!
All suggestions are welcome