Texturemap is applied to surface I don't want it to

I use texture mapping on a cylinder, which works fine, but for some reason the texture is also applied to the floor, that I draw with GL_QUADS filling four vertices. The code I use to draw the cylinder is:

void Tree::drawBranch() {
	glBindTexture(GL_TEXTURE_2D, BRANCH_TEXTURE); // BRANCH_TEXTURE is an int referring to the texture
	GLUquadricObj *branch = gluNewQuadric();
	gluQuadricDrawStyle(branch, GLU_FILL);
	gluQuadricTexture (branch, GL_TRUE    );

	glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, Colors::BROWN);
	gluCylinder(branch, startDiameter, startDiameter * BRANCH_TOP_TO_BOTTOM_RATIO, length, 25, 15);

and to draw the floor I do

void Scene::drawFloor() {
        glMaterialfv (GL_FRONT, GL_DIFFUSE, Colors::GREEN);
	glBegin( GL_QUADS );
		glVertex3d( -200.0, 0.0, 200.0 );
		glVertex3d(  200.0, 0.0, 200.0 );
		glVertex3d(  200.0, 0.0, -200.0 );
		glVertex3d( -200.0, 0.0, -200.0 );

I found a dirty solution by calling

glBindTexture(GL_TEXTURE_2D, -1);

at the end of the drawBranch()-function or the beginning of the drawFloor()-function. This solves my problem, but gives a segmentation fault when the program exits. But I don’t think that should be necessary, does anyone have a clue of what I’m doing wrong? If you need more code please say so!

Nevermind, I found it: the texture I loaded from file was bound to index 0, which is used as the default texture for everything. Now I bind it to index 1 and use index 0 when drawing the floor, problem && segfault solved :slight_smile:

you should disable texturing when you dont want a texture on your polygon.