Ahrezmendi
04-02-2003, 09:13 PM
Ok, I can't figure out why this won't draw anything. It compiles fine, no errors, but it draws a black screen. If I replace it with a series of plain aux calls, they all draw perfectly, but as soon as I put this for loop in there, it draws a black screen. Anybody got any suggestions?
objects_to_render = world.getGameObjects();
for(temp=0; temp < objects_to_render.size(); temp++)
{
test = objects_to_render[temp]->getObjectType();
// render an Asteroid
if(test == 1)
{
// asteroid rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// all setup, get the center and draw a sphere
// of size 4
// hideous and ugly, but should work
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// set the color and draw the asteroid
glColor3f(1.0f, 0.0f, 0.0f);
auxSolidSphere(4.0f);
glPopMatrix();
}
// render the Ship
else if(test == 4)
{
// ship rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// move object to it's location
// ugly again, but should work
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// the ship is special in that it can face different
// directions. Now we must get it's heading and rotate it
angle = arctan((objects_to_render[temp]->getOrientation().i),
(objects_to_render[temp]->getOrientation().j));
glRotatef(angle, 0.0f, 0.0f, 1.0f);
// set the color and draw the ship
glColor3f(1.0f, 1.0f, 0.0f);
auxSolidCone(2.5f, 10.0f);
glPopMatrix();
}
// render a bullet
else if(test == 5)
{
// bullet rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// move object to it's location
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// set the color and draw the bullet
glColor3f(0.0f, 1.0f, 0.0f);
auxSolidSphere(1.0f);
glPopMatrix();
}
}
objects_to_render = world.getGameObjects();
for(temp=0; temp < objects_to_render.size(); temp++)
{
test = objects_to_render[temp]->getObjectType();
// render an Asteroid
if(test == 1)
{
// asteroid rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// all setup, get the center and draw a sphere
// of size 4
// hideous and ugly, but should work
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// set the color and draw the asteroid
glColor3f(1.0f, 0.0f, 0.0f);
auxSolidSphere(4.0f);
glPopMatrix();
}
// render the Ship
else if(test == 4)
{
// ship rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// move object to it's location
// ugly again, but should work
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// the ship is special in that it can face different
// directions. Now we must get it's heading and rotate it
angle = arctan((objects_to_render[temp]->getOrientation().i),
(objects_to_render[temp]->getOrientation().j));
glRotatef(angle, 0.0f, 0.0f, 1.0f);
// set the color and draw the ship
glColor3f(1.0f, 1.0f, 0.0f);
auxSolidCone(2.5f, 10.0f);
glPopMatrix();
}
// render a bullet
else if(test == 5)
{
// bullet rendering - do in a bit
glPushMatrix();
glLoadIdentity();
// move object to it's location
glTranslatef((objects_to_render[temp]->getCenter().x),
(objects_to_render[temp]->getCenter().y),
(objects_to_render[temp]->getCenter().z));
// set the color and draw the bullet
glColor3f(0.0f, 1.0f, 0.0f);
auxSolidSphere(1.0f);
glPopMatrix();
}
}