PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PF blending problem

I don't know, maybe my question is lame, but i'm just learning PF anyway...

I wanted to make a shadow of box jbject, so i made a black square and drawn it with SetBlending(4). Everething was fine exept it blended PINK. Any value less than 8 resulted pink shadow, any bigger than 7 - full black square. Is that how it suppose to work? If that so, can anyone tell me how to create fast and good looking shadow? %)
can you post a code snippet so I can figure out that you are doing wrong?
as far as i remember
(sources are at home :( )

Code:

void MyGame::LoadResources()
{
DisplayDevice* m_pDD = GetDisplay();
Surface* m_objects[15];
// blah blah blah
m_objects[14] = LoadImag(m_pDD,IDB_SHADOW);
for(int tmp=;tmp<15;tmp++)
m_objects[tmp]->SetColorMask(Color(255,0,255));
// IDB_SHADOW is a black square 20x20
}
void MyGame::DrawShadow(int x,int y)
{
m_pDD->SetBlending(4);
m_pDD->Blit(x,y,m_objects[14]);
m_pDD->SetBlending(255);
}

[/code]
darn, forgot nick :)
looking at it now. Your colour mask is set to 255,0,255 which is magenta (or pink if you prefer). I assume your images have transparent parts which are that colour?

Set blending merges a percentage of your foreground image with the background. Is that what you want? I'm not certain what you mean by a shadow exactly. Are you drawing the shadow & then the image on top of it slightly offset
not exactly
i'm drawing an object and trying to draw darkened square on background near in. I've tried direct pixel access but it was slow. Now i want to blend semitranspanent black square to darken a part of background :)
Code:
r_fillrect.Set(159,11,225,77);//the rect which will be filled
display->SetBlending(80);//alpha blend
display->FillRect(r_fillrect,Color(0,0,0));//background to wee planets display

these lines darken the background of the rectangle specified, does this help?
Yes, THANKS!

Man, i have to learn and learn more wisdom of PocketFrog :)
glad to be of help, here's another gem, these lines cause PF only to draw within the rectangle shown
Code:
r_fillrect.Set(159,11,225,77);//the rect which will be clipped
display->SetClipping(r_fillrect);//only draw in this rect

r_fillrect.Set(0,0,240,320);//back to normal
display->SetClipping(r_fillrect);
i found bug! it was in my DNA :)
my code called DrawShadow several times for each box, no wonder it gone pink... er... magenta ;)