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


C++ CEngine::GetWindow方法代码示例

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


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

示例1: Init

bool CDirectEngine::Init(const CEngine& aEngine, Vector2<unsigned int> aWindowSize, bool enableVSync, bool startInFullScreen)
{
    myEnableVSync = enableVSync;
    HRESULT result = S_OK;

    INFO_PRINT( "%s", "Starting engine" );

    myWindowSize = aWindowSize;
    DXGI_SWAP_CHAIN_DESC swapChainDescription;
    ZeroMemory( &swapChainDescription, sizeof( DXGI_SWAP_CHAIN_DESC ) );
    // fill the swap chain description struct
    swapChainDescription.BufferCount = 1;
    swapChainDescription.BufferDesc.Width = myWindowSize.x;
    swapChainDescription.BufferDesc.Height = myWindowSize.y;
    swapChainDescription.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

    Vector2<int> numDenum;

	IDXGIAdapter* adapter = nullptr;
	if (CollectAdapters(aWindowSize, numDenum, adapter))
    {
        INFO_PRINT( "%s%s", "VSYNC Compatible: Yes, Enabled: ", myEnableVSync ? "Yes" : "No" );
    }

    swapChainDescription.BufferDesc.RefreshRate.Numerator = numDenum.x;
    swapChainDescription.BufferDesc.RefreshRate.Denominator = numDenum.y;

    swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swapChainDescription.OutputWindow = aEngine.GetWindow().GetWindowHandle();
    swapChainDescription.SampleDesc.Count = 1;
	swapChainDescription.Windowed = !startInFullScreen;
    swapChainDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
    swapChainDescription.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
    swapChainDescription.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
    swapChainDescription.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if defined(_DEBUG)
#if defined(REPORT_DX_WARNIGNS)
	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
#endif
    // create a device, device context and swap chain using the information in the scd struct
    INFO_PRINT( "%s", "Creating device" );
	D3D_FEATURE_LEVEL feat_level;
	result = D3D11CreateDeviceAndSwapChain(adapter,
		D3D_DRIVER_TYPE_UNKNOWN,
        NULL,
        creationFlags,
		supported_feature_levels,
		NUM_SUPPORTED_FEATURE_LEVELS,
        D3D11_SDK_VERSION,
        &swapChainDescription,
        &mySwapchain,
        &myDevice,
		&feat_level,
        &myDeviceContext );

#if defined(_DEBUG)
	if (FAILED(result))
	{
		D3D_FEATURE_LEVEL feat_level;
		ERROR_AUTO_PRINT("%s", "Device could not create itself in debug mode, trying without debug layer... If you have Win10, try this:  Settings panel -> System -> Apps & features -> Manage optional Features -> Add a feature -> Select ""Graphics Tools""");
		UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

		INFO_PRINT("%s", "Creating device without debug layer");
		result = D3D11CreateDeviceAndSwapChain(adapter,
			D3D_DRIVER_TYPE_UNKNOWN,
			NULL,
			creationFlags,
			supported_feature_levels,
			NUM_SUPPORTED_FEATURE_LEVELS,
			D3D11_SDK_VERSION,
			&swapChainDescription,
			&mySwapchain,
			&myDevice,
			&feat_level,
			&myDeviceContext);
	}
#endif

	if (!myDeviceContext)
	{
		ERROR_AUTO_PRINT("%s", "Device context error, you might not have a DX11 supported grahics card");
		return false;
	}

	if (FAILED(result) || !mySwapchain || feat_level == D3D_FEATURE_LEVEL_10_0)
    {
        ERROR_AUTO_PRINT( "%s", "Device swap error, you might not have a DX11 supported grahics card" );
        return false;
    }

	SetDebugObjectName(myDeviceContext, "myDeviceContext");

    myD3dDebug = nullptr;
#ifdef _DEBUG
    if( SUCCEEDED( myDevice->QueryInterface( __uuidof( ID3D11Debug ), (void**)&myD3dDebug ) ) )
    {
        ID3D11InfoQueue *d3dInfoQueue = nullptr;
//.........这里部分代码省略.........
开发者ID:wardh,项目名称:ZeldaClone,代码行数:101,代码来源:direct_3d.cpp


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