Advertisement

32 bit Display problem

Started by June 22, 2001 03:32 PM
1 comment, last by vbisme 23 years, 7 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 mode


DDSURFACEDESC2	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[i + ddsd.lPitch * j] = RGB32BIT(0, red, green blue);
		}
	}//end for

	

	lpPrimarySurface->Unlock(NULL);

  
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?
Nobody could help?
Advertisement
buffer is a pointer to bytes, so all your r bits would be cut off.

Try making it a pointer to an unsigned int (32-bits).


War Worlds - A 3D Real-Time Strategy game in development.

This topic is closed to new replies.

Advertisement