Texture colors 'bleeding' to other vertices

Hey guys,

I’m having a problem with the color of the last drawn texel bleeding to untextured vertices. The following image shows what’s happening:

http://img156.imageshack.us/img156/2077/problem01nc1.th.png

I draw a face of the cube with the blue texture (last corner of the texture is brown), then I draw 4 white quads which turn brown for some reason. The last quad has a yellow texture. I then draw a piramid using 1 quad and 1 triangle fan. Although it should be white aswell, it also gets the color from the texture I last used.

This is the code that draws the face:

[code=Java]
public void draw(GL gl)
{
int i;
if(texture != null)
gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureObject());
switch(type)
{
case TYPE_QUAD :
gl.glBegin(GL.GL_QUADS);
break;
case TYPE_TRIANGLE_FAN :
gl.glBegin(GL.GL_TRIANGLE_FAN);
break;
default:
throw new RuntimeException("Unknown face type for mesh " + mesh.id);
}

    for(i = 0;i < indices.length;i++)
    {
        if(texture != null)
            gl.glTexCoord2f(TEXTURE_COORD[i * 2], TEXTURE_COORD[i * 2 + 1]);
        gl.glColor3fv(mesh.colors, indices[i] * 3);
        gl.glVertex3fv(mesh.vertices, indices[i] * 3);
    }
    gl.glEnd();
}


What am I missing? Thanks!

Right! Somebody on another forum helped me, I didn’t know I had to unbind textures:

[code=Java]
if(texture != null)
gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureObject());
else
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);