PDA

View Full Version : Texture blending without RGBA



nickcartwright
10-13-2003, 02:20 AM
I'm having a bit of greif with the snippet below.

What i'm trying to do is draw some grass, then on-top draw some snow.

The grass and snow both draw fine when the other isn't being drawn... i can't seem to get them to be drawn together.

I'm sure this is a really simple mistake - can anyone spot it?




// Draw Grass

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 1);
glBegin(GL_QUADS);
glColor4f(1.0, 1.0, 1.0, 1.0);

// Draws the grass tile

glEnd();

// Draw Snow
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, 2);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_QUADS);
glColor4f(1.0, 1.0, 1.0, 0.5);

// Draws the snow tile

glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);


[This message has been edited by nickcartwright (edited 10-13-2003).]

[This message has been edited by nickcartwright (edited 10-13-2003).]

147-2
10-13-2003, 11:19 AM
Looks like you need glColorMaterial turned on so that you can glColor4f() and have textures at the same time. I may be mislead here though. I suppose you can also try affecting the color matrix as well. You shouldn't need to have an alpha channel in your texture though.

soconne
10-13-2003, 05:45 PM
You could try setting the alpha for the first texture to 0.5, or maybe setting the alpha in glClearColor to 0.5 or 0 if it's at 1.

//texture 1
glColor4f(1,1,1,0.5);
glClearColor(1,1,1,0);

This might work.