当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAW::CreatePalette方法代码示例

本文整理汇总了C++中LPDIRECTDRAW::CreatePalette方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW::CreatePalette方法的具体用法?C++ LPDIRECTDRAW::CreatePalette怎么用?C++ LPDIRECTDRAW::CreatePalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAW的用法示例。


在下文中一共展示了LPDIRECTDRAW::CreatePalette方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WinMain

/********************************************************************
* Function : WinMain()
* Purpose : Mandatory Windows Init function.
********************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
						 LPSTR lpCmdLine, int nCmdShow)
{
	MSG		msg;
	HWND		hwnd;
	WNDCLASS	wc;
	static char ClassName[] = "ChromeTestingFacility";
	DDSURFACEDESC	ddsd;
	DDSCAPS			ddscaps;
	HRESULT			ddreturn;
	int n;

	// Set all key booleans to FALSE, assume no key is pressed.
	bForwardKey = FALSE;
	bBackKey = FALSE;
	bLeftKey = FALSE;
	bRightKey = FALSE;
	nState = 0;
	nGauge = 0;

	lpCmdLine = lpCmdLine;
	hPrevInstance = hPrevInstance;
	RealTime = 0;	/* Start of using spacebar for frameflipping. */

	/* Register and realize our display window */
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = ClassName;
	wc.lpszClassName = ClassName;
	RegisterClass(&wc);

	/* Initialize our test world. */
	if (!InitWorld(XRES, YRES, Colormap))
	{	return FALSE;
	}

	/* Convert the Chrome colormap to a windows colormap. */
	for (n = 0; n < 256; n++)
	{
		WinColormap[n].peRed = (unsigned char)((Colormap[n] & 0xFF0000) >> 16);
		WinColormap[n].peGreen = (unsigned char)((Colormap[n] & 0xFF00) >> 8);
		WinColormap[n].peBlue = (unsigned char)((Colormap[n] & 0xFF));
		WinColormap[n].peFlags = 0;
	}
	/* Create a full screen window so that GDI won't ever be
	 * called. */
	hwnd = CreateWindowEx(WS_EX_TOPMOST,
								 ClassName,
								 ClassName,
								 WS_POPUP,
								 0,
								 0,
								 GetSystemMetrics(SM_CXSCREEN),
								 GetSystemMetrics(SM_CYSCREEN),
								 NULL,
								 NULL,
								 hInstance,
								 NULL);
	if (hwnd == NULL)
		return FALSE;
	
	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);
	SetFocus(hwnd);
	ShowCursor(FALSE);		/* Remove cursor to prevent GDI from writing. */

	/* Instanciate our DirectDraw object */
	ddreturn = DirectDrawCreate(NULL, &lpDirectDrawObject, NULL);
	if (ddreturn != DD_OK)
	{
		DestroyWindow(hwnd);
		return FALSE;
	}

	ddreturn = lpDirectDrawObject->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX);
	if (ddreturn != DD_OK)
	{
		DestroyWindow(hwnd);
		return FALSE;
	}

	/* Create a palette for the surfaces. */
	ddreturn = lpDirectDrawObject->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE,
																(LPPALETTEENTRY)WinColormap,
																&lpPalette,
																NULL);
	if (ddreturn != DD_OK)
	{	DestroyWindow(hwnd);
		return FALSE;
	}
//.........这里部分代码省略.........
开发者ID:kingletbv,项目名称:chrome2k,代码行数:101,代码来源:dxmain.cpp


注:本文中的LPDIRECTDRAW::CreatePalette方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。