Boolean Help

Another Day, Another Problem! Heh, but this one is truely confusing me, due to the fact i think it should be working. Basically I am trying to create textures based on the position of an object, so i have created a function seen below:

void DropFunc(void){
if (Drop == true)
{
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture[2]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(DropTileX + 0.0,0.1,DropTileZ + 5.0);
glTexCoord2f(1.0f, 0.0f); glVertex3f(DropTileX + 5.0,0.1,DropTileZ + 5.0);
glTexCoord2f(1.0f, 1.0f); glVertex3f(DropTileX + 5.0,0.1,DropTileZ + 0.0);
glTexCoord2f(0.0f, 1.0f); glVertex3f(DropTileX + 0.0,0.1,DropTileZ + 0.0);
glEnd();
glPopMatrix();
glutPostRedisplay();
Drop = false;
}
}

This is the formula for the x and z values:

int DropTileX = (Dropi * 5) - 5;
int DropTileZ = (Dropj * 5) - 5;

where Dropi and Dropj are constantly being updates by the moving object, so you press the right key and j increases by 1 etc. This function should basically (as far as i know) create a square with the desired vertex, and apply texture[2] to that object. I know this as it works elsewhere in my code (and basically forms the grid my objects move about). Except for this placement, I have increased the y co-ord by 0.1 so it sits above the main floor.

In my drop key i have:

case ‘X’: //drops bottom texture
case ‘x’: Drop = true;
glutIdleFunc(DropFunc);
glutPostRedisplay(); // Redisplay with dropped textures
break;

which as far as I know sets Drop to true, which should activate the function, then it should create the tile as described, then set drop to false so it doesnt loop.

If anyone can understand what i’m trying to do, can you help me?

Thanks,

EJD

Hi,

What exactly is the problem?
No texture?, no quad? empty display?

Ido

Am I blind, I just can’t find what is your problem in your post, you only talk about what you should obtain. You see nothing?

Does it work putting simple values in the glVertex3d calls?
How do you set your projection matrix?
Are you sure the geometry is in the view volume? Especially z coordinate that should be in the [znear zfar] range.

By the way, the glPush/glPop calls are useless in your case.

Hey sorry i’m not very good at explaining. The basic issue was that it wasnt displaying, but that is because I forgot to call the function that displays it in main. The issue I have now, yes i gained another one, is that due to the way I have written it. I can now drop the texture, but it follows under the cube, i.e the variables DropTileX and DropTileZ are constantly updating with every move made. Is there anyway to stop this, i’m thinking storing the created textures in an array? but have no idea how to do it.