Hello !
I have written a method in my Class which sould draw a Pixel on the
Surface !
It gets a X and Y coordination and a color(Uint32).
I am doing following:
void gfx::drawPixel(unsigned int x,unsigned int y,Uint32 color)
{
Uint8* bits,bpp;
Uint32
col=SDL_MapRGB(area()->format,color&0xFF0000,color&0x00FF00,color&0x0000FF);
if(SDL_MUSTLOCK(area()))
{
if(SDL_LockSurface(area()))
return;
}
bpp=area()->format->BytesPerPixel;
bits=((Uint8*) area()->pixels)+yarea()->pitch+xbpp;
// I am in 16Bit color depth
*((Uint16 *)(bits)) = (Uint16)col;
cout << “bpp->2” << endl;
break;
}
So when I call this method in a loop
which should draw Pixels at a random position in a
random color, I only got Blue pixels !
eg:
srand(time(NULL));
gfx g;
while(!done)
{
g->drawPixel(rand()%640,rand()%480,rand());
}
Can anybody explain me why the pixels are all blue ???
What I am doing wrong ???
Thank you and best regrads.
Ciao
Anes