32 bit Display problem

Started by
0 comments, last by vbisme 22 years, 10 months ago
I''m trying to write some pixels to the screen using DirectDraw7 under 32 bit display:
  
#define RGB32BIT(a, r, g, b) ( ((a) << 24) + ((g) << 8) + ((r) << 16) + (b) )	//RGB32BIT color modeDDSURFACEDESC2	ddsd;	ZeroMemory(&ddsd, sizeof(ddsd));	ddsd.dwSize = sizeof(ddsd);	lpPrimarySurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);	PBYTE	buffer = (PBYTE)ddsd.lpSurface;		BYTE red, blue, green;	blue = (BYTE)0;	green = (BYTE)0;	red = BYTE(255);		for (int i = 0; i < 500; i++)	{		for (int j = 0; j < 50; j++)		{			buffer = RGB32BIT(0, red, green blue);		}	}//end for		lpPrimarySurface-&gt;Unlock(NULL);
  </font></pre></font></td></tr></table></center><!–ENDSCRIPT–>

The display is black instead of red. I''ve tried loading bitmap values from a .bmp file the the display color is still incorrect. It seems I can only plot pixels with shades from black to white. How can I get this to work correctly? 

    
Advertisement
Hello,

I''m not sure if this will help, but I''d try casting your surface pointer to an unsigned int - I''m not familiar with PBYTE so I presume it''s your own typedef...

Also I''d check to see whether r-g-b-a works instead of a-r-g-b, I''ve had almost identical problems and a combination of the above was the answer.

oOO!! if you cast the surface ptr to an unsigned int....you''ll have to be careful with the lPitch...remember lPitch is specified in bytes, so an int is 4 bytes...so I think you have to do lPitch/4 (or >> 2) when actually setting the pixels...

no doubt there is something erroneous in what I''ve said but I''m sure someone will correct it...

hope I''ve helped a bit 8O)

This topic is closed to new replies.

Advertisement