Ok I got the colors working now, but I think the way I'm addressing the pixels is wrong...I noticed that in my test program if i use a loop like this:
Code:
for (int y=0;y<SCREEN_HEIGHT;y++)
for (int x=0;x<SCREEN_WIDTH;x++)
//plot pixel
It only draws half the screen (the upper half, to be exact). Oh I'm using DirectDraw, and I set the display mode like this:
Code:
if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,32,0,0)))
{
MessageBox(NULL,"SetDisplayMode() Failed!","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 0;
}
But I don't get an error, so it seems that its setting the display mode correctly.
Ok, boiling it down this is my pixel-plotting function:
Code:
void Plot_Pixel32(int x,int y,int r,int g,int b,USHORT* video_buffer,int lpitch32)
{
UINT pixel = __RGB32BIT(0,r,g,b); //ignoring alpha bits, since image is actually 24 bit
video_buffer[x+y*lpitch32]=pixel; //where lpitch23 is lpitch>>2
}
Anyone have any idea whats going on?
EDIT:
I changed it to video_buffer[((x+(y*lpitch32)*2)]=pixel
and that seems to work, but now I noticed that the colors aren't correct, just very close...black is black, but white is a bluish color...if i have R=255 G=255 B=255 it comes out bluish, so its not just my image...
Code:
#define __RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))
Thats the macro I'm using to put all the color data together, and I'm actually using macros to separate R G and B out of the pixel data I read from the image, so its easy to switch back and forth from hard-coded colors (i.e. 255,255,255) and my image data. Like I said, it seems to make no difference whether i use my image data or equivalent numbers. Should it matter that I have 0 as my alpha bits?
EDIT2:
No matter what I do I can't get any red in my program! At least I know its not my image loader, but I can't figure out why it wont display red!!