Transparent objects - Blending

I have this code:

void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(transx,0.0f,transz);
glRotatef(rotx,1.0f,0.0f,0.0f);
glRotatef(roty,0.0f,1.0f,0.0f);


glBindTexture(GL_TEXTURE_2D,texture[1]);
gluSphere(quadric,0.3f,30,30);
	
if (blending) {
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
glColor4f(1.0f,1.0f,1.0f,0.5f);	
}
else {
	glEnable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);
} 

glBindTexture(GL_TEXTURE_2D, texture[0]);
DrawCube(0.0f,0.0f,0.0f,1.0f);
	
glutSwapBuffers();

}

When I press b, I have blending…but both cube and sphere are transparent…I want only the cube to be transparent. I tried to draw the sphere after the cube and although it wasn’t transparent, it didn’t look it was IN the cube. Any suggestions?

The blend state is persistent and lasts forever or until it is set again into the next frame. This is true for all OpenGL state.

Disable blending after the cube is drawn or before the sphere is drawn and it will work.