PDA

View Full Version : I am wondering if there is a bug in the drawalpha routine?



czar
15-01-2004, 04:33 AM
I was hoping to upload a bitmap to show what I mean, but I seem to be having a spot of bother.

And now after quickly reading the FAQ I find out I cannot remove my post :(

czar
15-01-2004, 04:48 AM
Still not 100% sure that there is a bug in the drawalpha or drawadd but after looking up a page on deja I made a few changes to the drawadd function, and bang it works as I want it to work. Here is the code


procedure TGLXImageItem.DrawAdd(X, Y, PatternIndex: Integer; Alpha: Single);
begin
glColor4f(1.0,1.0,1.0,Alpha);

glPushAttrib(GL_ENABLE_BIT);
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);

// glBlendFunc(GL_SRC_ALPHA,GL_ONE);

{next two lines added by myself}

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0);

Bind;

glBegin(GL_QUADS);
with FPatterns[PatternIndex] do begin
glTexCoord2f(Left , Bottom); glVertex2i(X , Y);
glTexCoord2f(Right, Bottom); glVertex2i(X+PatternWidth, Y);
glTexCoord2f(Right, Top ); glVertex2i(X+PatternWidth, Y+PatternHeight);
glTexCoord2f(Left , Top ); glVertex2i(X , Y+PatternHeight);
end;
glEnd();
glPopAttrib();
glColor4f(1.0,1.0,1.0,1.0);
end;

Andreaz
15-01-2004, 07:19 AM
no it's not an bug in the drawadd, what you are trying to do should be done as following:


GLXDraw1.UseColor(1.0, 1.0, 1.0, 0.2);
GLXImageList1.Items.Find('Wood.jpg').Draw(20,20, 0);
GLXDraw1.UseColor(1.0, 1.0, 1.0, 1.0);

czar
15-01-2004, 07:30 AM
Thanks for the help. I tried it and thats works fine.