View Full Version : Using for to draw multiple objects?

02-20-2012, 09:25 AM
Hello people!

I'm trying to make a system which draws a quad (summons an archer) at a certain location relative to the player.
I want it to be possible to summon a multitude of these.

My problem is that when I press the button to summon one of these, the previously summoned one disappears.

Pressing the button first adds 1 to 'archernumber', then sets the 'ux' (x position), uy and 'uz' to the players current position. Lastly it sets 'summoned' to TRUE.
Code section from the drawglscene which draws these polygons:

for (int archerdraw=0; archerdraw <= archernumber; archerdraw++) //draw archer
if (archer[archernumber].summoned &amp;&amp; archernumber != 0)
// Front Face
glVertex3f(-0.25f, -0.25f, 0.25f); // Bottom Left Of The Texture and Quad
glVertex3f( 0.25f, -0.25f, 0.25f); // Bottom Right Of The Texture and Quad
glVertex3f( 0.25f, 0.25f, 0.25f); // Top Right Of The Texture and Quad
glVertex3f(-0.25f, 0.25f, 0.25f); // Top Left Of The Texture and Quad

So what I need to know is why this code does not allow the existence of multiple quads, in other words why the previous quad disappears once I draw the next one.
Any help on how to fix this or what might be a better way of doing it is greatly appreciated.

On a side note: Can anyone tell me if there is something like glPushMatrix() that works on colours?
Many thanks in advance.

carsten neumann
02-20-2012, 11:55 AM
Why is the loop counter variable archerdraw not used to index the archer array? I see nothing in the posted snippet that changes archernumber...