PDA

View Full Version : Overpainted color influenced by texture format ?!



Casius
10-08-2008, 11:49 PM
Hello,
I got a loop for drawing several quads. Each quad got itīs own texture.In the loop the z-Values for each quadīs vertices are getting bigger, to draw each quad deeper in space.
When one quad is selected, itīs possible to adjust itīs opacity.

I draw a frame around the selected quad in red. But when chancing active quad the frame color is variing in intensity. Itīs still red, but one is lighter others are darker.

btw:
- when drawing e.g. 8 quads it wonīt get lighter and lighter, that you could think of somthing is accumulated. itīs like red-lighter-stil_lighter-dark-red-light (hope you know what i mean)
- The frame donīt change its opacity. But same effect, neither drawing it before the selected quad nor afterwards.
**break break!!!
Now you know the effect. I now why - Textures Format is changing the red-Intensity!?! But why?

Alle texture have 24bpp an 72dpi - just different sizes and different formats. bmp is light, png dark.

So could you please check my code of the loop and help me breaking the secret of drawing the frame totally undependent ot the textureīs formate or the color "state".

In init() i just do

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_COLOR_MATERIAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

paint():
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslated(0.0, 0.0, -10.0);
if (i=0; i<quads_array.size(); i++)
.....caling drawQuad(i);

drawQuad(int i):
GLFloat z = i*0.5f;

if (ID == activeQuad){
glDisable(GL_BLEND);
//draw red activation frame
glColor4f(1.0f,0.0f,0.0f,1.0f);
glLineWidth (2.0f);
glBegin (GL_LINE_LOOP);
glVertex3f (-sizeX, +sizeY, z);
glVertex3f (+sizeX, +sizeY, z);
glVertex3f (+sizeX, -sizeY, z);
glVertex3f (-sizeX, -sizeY, z);
glVertex3f (-sizeX, +sizeY, z);
glEnd();
//resetColor
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_BLEND);
}

//color for material to adjust blending
glColor4f(1.0f,1.0f,1.0f,alpha[ID]);
//bind texture to layer
glBindTexture(GL_TEXTURE_2D, textures[ID]);
//draw quad with according size
glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex3d(-sizeX, +sizeY, z);
glTexCoord2d(1,0); glVertex3d(+sizeX, +sizeY, z);
glTexCoord2d(1,1); glVertex3d(+sizeX, -sizeY, z);
glTexCoord2d(0,1); glVertex3d(-sizeX, -sizeY, z);
glEnd();
//reset color
glColor4f(1.0f,1.0f,1.0f,1.0f);
}
//eof

Thanks a lot for your hints.

ZbuffeR
10-09-2008, 05:07 AM
Pretty simple : when don't want texturing anymore, you have to say it, like with the glColor.
glDisable(GL_TEXTURE_2D);
// here draw color frame
glEnable(GL_TEXTURE_2D);
// here draw textured quad

Casius
10-13-2008, 12:33 AM
Thanks again - Works fine!!