I have a particle system and one of the behaviors is Smoke. So each particle starts small and grows big until it fades away. A problem with this is the fact that since the texture is being enlarged, it appears as if it is moving to the right. This can be resolved by rendering the particle´s x position minus half its width. However, this small division when coupled with thousands of particles can cause performance drops. My question is, is there another way to remove the “drifting to the right” bug? Perhaps an optimization? My code with the division is…
P.S. The bug also affects the image to look like its drifting down. Thus the minus half the height in the code:
glBegin(GL_QUADS);
glTexCoord2f(ci.getXD(),ci.getYD());// Upper-left
glVertex2i((int)p.getX()-p.getWidth()/2, (int)p.getY()-p.getHeight()/2);
glTexCoord2f(ci.getXWD(), ci.getYD());// Upper-right
glVertex2i((int)p.getX()+p.getWidth()/2, (int)p.getY()-p.getHeight()/2);
glTexCoord2f(ci.getXWD(), ci.getYHD());// Bottom-right
glVertex2i((int)p.getX()+p.getWidth()/2, (int)p.getY()+p.getHeight()/2);
glTexCoord2f(ci.getXD(), ci.getYHD()); // Bottom-left
glVertex2i((int)p.getX()-p.getWidth()/2, (int)p.getY()+p.getHeight()/2);
glEnd();