Texture trouble

I’m trying to texture a rectangle, easy enough. But the problem is: there’s transparency in the image, and black, and other colours. What’s black also becomes transparent.
I use:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glEnable(GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glEnable(textureTarget);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0, h);
glTexCoord2f(0, im.imgh); glVertex2f(0, 0);
glTexCoord2f(im.imgw, im.imgh); glVertex2f(w, 0);
glTexCoord2f(im.imgw, 0); glVertex2f(w, h);
glEnd();
glDisable(textureTarget);
glDisable(GL_BLEND);

Thanks for helping out.

That’s happening because it’s what you’ve told OpenGL to do, specifically in these lines:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glEnable(GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

Fastjack, can you explain what results you want ?

I want the image completely displayed, except the parts that are transparent. Black should be displayed as black, transparent should be transparent, other colours should be other colours. I’m not sure what the right settings are for this effect.

Then you need glBlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA)

or GL_ONE, ONE_MINUS_SRC_ALPHA if your textures have premultiplied alpha.

neither work, first turns transparent black, second turns black transparent

Sorry for you then, because it means you are doing something else wrong.
Are you certain you draw the translucent part last ? Otherwise the depth buffer can get in the way.
Are you certain that alpha is 0 for transparent texels, and 255 for fully visible texels ?

I am drawing the translucent part last.
To my astounishment the alpha is not 0, but very low (0x01) for transparent texels, 255 for fully visible texels.

I don’t know what to do…

Reduce your code to the smaller compilable Glut program still showing your problem, and post it here.