Here is the code I have that whenever I run throws a "Iterator not incrementable" error at run time. If I comment out the sp++ line or the asteroids.push_back(*sp); line then it runs fine. So it has something to do with those lines...I saw in a previous post that the line sp->getSize() is incremented the pointer as well and may be the cause of the issues? thanks for the help!
while(sp != asteroids.end()){
if(sp->getSize() == .5 || sp->getSize() == 0.25){
glPushMatrix();
glScalef(.1, .1, .1);
glTranslatef(3,3,0);
sp->display_asteriod(sp->getSize(), random, randomTwo);
glPopMatrix();
asteroidCount++;
spawn.setSize(sp->getSize());
//spawn.setLife(it->getLife());
random = ((double) rand() / (RAND_MAX+1));
randomTwo = ((double) rand() / (RAND_MAX+1)) * 7;
spawn = createAsteroid(spawn);
x_speed_asteriod = (spawn.getXDirection())*(spawn.getRandomVelocity());// + x_speed_asteriod;
y_speed_asteriod = (spawn.getYDirection())*(spawn.getRandomVelocity());// + y_speed_asteriod;
spawn.setXSpeed(x_speed_asteriod);
spawn.setYSpeed(y_speed_asteriod);
if(spawn.getRandomAxis() == 0){
glRotatef(spawn.getAngleRotation(), 1, 0, 0);
}else if(spawn.getRandomAxis() == 1){
glRotatef(spawn.getAngleRotation(), 0, 1, 0);
}else if(spawn.getRandomAxis() == 2){
glRotatef(spawn.getAngleRotation(), 0, 0, 1);
}
//it = asteroids.begin() + asteroidCount;
//asteroids.insert(it, spawn);
//asteroids.resize(asteroidCount);
asteroids.push_back(*sp);
glPushMatrix();
glScalef(.1,.1,.1);
glTranslatef(spawn.getXPosition()-3, spawn.getYPosition()-3, 0);
spawn.display_asteriod(spawn.getSize(), random, randomTwo);
glPopMatrix();
}else{
sp++;
}