예제 #1
0
HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
	DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
	IDirect3DDevice9** ppReturnedDeviceInterface)
{
	// load configuration file
	ProxyHelper helper = ProxyHelper();
	ProxyHelper::ProxyConfig cfg;
	bool stereoificatorCfgLoaded = helper.LoadConfig(cfg);

	if (cfg.forceAdapterNumber >= (int)GetAdapterCount()) {
		OutputDebugString("[ERR] forceAdapterNumber outside of range of valid adapters. Using original Adapter instead.\n");
	}

	// Create real interface
	HRESULT hResult = m_pD3D->CreateDevice( (cfg.forceAdapterNumber >= (int)GetAdapterCount() || (cfg.forceAdapterNumber < 0)) ? Adapter : cfg.forceAdapterNumber, DeviceType, hFocusWindow, BehaviorFlags,
		pPresentationParameters, ppReturnedDeviceInterface);
	if(FAILED(hResult))
		return hResult;

	OutputDebugString("[OK] Normal D3D device created\n");

	char buf[64];
	sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount);
	OutputDebugString(buf);

	
	if(!stereoificatorCfgLoaded) {
		OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Stereoificator will not be active.\n");
		return hResult;
	}

	OutputDebugString("[OK] Config loading - OK\n");

	

	char buf1[32];
	LPCSTR psz = NULL;

	wsprintf(buf1,"Config type: %d", cfg.game_type);
	psz = buf1;
	OutputDebugString(psz);
	OutputDebugString("\n");

	// Create and return proxy
	D3DProxyDevice* newDev = new D3DProxyDevice(*ppReturnedDeviceInterface, this, cfg);
	*ppReturnedDeviceInterface = newDev;

	OutputDebugString("[OK] Stereoificator D3D device created.\n");

	return hResult;
}
예제 #2
0
/**
* Create D3D device proxy. 
* First it creates the device, then it loads the game configuration
* calling the ProxyHelper class. Last it creates and returns the
* device proxy calling D3DProxyDeviceFactory::Get().
***/
HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface)
{
	// Create real interface
	HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags,
		pPresentationParameters, ppReturnedDeviceInterface);
	if(FAILED(hResult))
		return hResult;

	OutputDebugString("[OK] Normal D3D device created\n");

	char buf[64];
	sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount);
	OutputDebugString(buf);

	// load configuration file
	ProxyHelper helper = ProxyHelper();
	ProxyHelper::ProxyConfig cfg;
	ProxyHelper::OculusProfile oculusProfile;
	if(!helper.LoadConfig(cfg, oculusProfile)) {
		OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n");
		return hResult;
	}

	// load HUD/GUI settings
	helper.LoadHUDConfig(cfg);
	helper.LoadGUIConfig(cfg);

	OutputDebugString("[OK] Config loading - OK\n");

	if(cfg.stereo_mode == StereoView::DISABLED) {
		OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n");
		return hResult;
	}

	OutputDebugString("[OK] Stereo mode is enabled.\n");

	char buf1[32];
	LPCSTR psz = NULL;

	wsprintf(buf1,"Config type: %d", cfg.game_type);
	psz = buf1;
	OutputDebugString(psz);
	OutputDebugString("\n");

	// Create and return proxy
	*ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this);

	OutputDebugString("[OK] Vireio D3D device created.\n");

	return hResult;
}
예제 #3
0
/**
* Create D3D device proxy.
* First it creates the device, then it loads the game configuration
* calling the ProxyHelper class. Last it creates and returns the
* device proxy calling D3DProxyDeviceFactory::Get().
***/
HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
{
	// Create real interface
	HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags,
		pPresentationParameters, ppReturnedDeviceInterface);
	if (FAILED(hResult))
		return hResult;

	OutputDebugString("[OK] Normal D3D device created\n");

	char buf[64];
	sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount);
	OutputDebugString(buf);
	sprintf_s(buf, "Format of back buffers = %x\n", pPresentationParameters->BackBufferFormat);
	OutputDebugString(buf);

	// for debug reasons, output the d3dswapeffect parameter
	switch (pPresentationParameters->SwapEffect)
	{
	case D3DSWAPEFFECT::D3DSWAPEFFECT_COPY:
		OutputDebugString("D3DSWAPEFFECT_COPY");
		break;
	case D3DSWAPEFFECT::D3DSWAPEFFECT_DISCARD:
		OutputDebugString("D3DSWAPEFFECT_DISCARD");
		break;
	case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIP:
		OutputDebugString("D3DSWAPEFFECT_FLIP");
		break;
	case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIPEX:
		OutputDebugString("D3DSWAPEFFECT_FLIPEX");
		break;
	case D3DSWAPEFFECT::D3DSWAPEFFECT_OVERLAY:
		OutputDebugString("D3DSWAPEFFECT_OVERLAY");
		break;
	default:
		char buf[256];
		sprintf_s(buf, 256, "D3DPRESENT_PARAMETERS::SwapEffect %x", pPresentationParameters->SwapEffect);
		OutputDebugString(buf);
		break;
	}

	// if no back buffer present (=D3DFMT_UNKNOWN), return base device - TODO !!! 
	// DOES NOT WORK since the shaders will not be wrapped by the base device
	// create a special device for that.....
	/*if ((pPresentationParameters->BackBufferCount == 0) && (pPresentationParameters->BackBufferFormat == D3DFORMAT::D3DFMT_UNKNOWN))
	{
	*ppReturnedDeviceInterface = new BaseDirect3DDevice9(*ppReturnedDeviceInterface, this);
	return hResult;
	}*/

	// load configuration file
	ProxyHelper helper = ProxyHelper();
	ProxyHelper::ProxyConfig cfg;
	ProxyHelper::OculusProfile oculusProfile;
	if (!helper.LoadConfig(cfg, oculusProfile)) {
		OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n");
		return hResult;
	}

	OutputDebugString("[OK] Config loading - OK\n");

	if (cfg.stereo_mode == StereoView::DISABLED) {
		OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n");
		return hResult;
	}

	OutputDebugString("[OK] Stereo mode is enabled.\n");

	char buf1[32];
	LPCSTR psz = NULL;

	wsprintf(buf1, "Config type: %d", cfg.game_type);
	psz = buf1;
	OutputDebugString(psz);
	OutputDebugString("\n");

	// Create and return proxy
	*ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this);

	OutputDebugString("[OK] Vireio D3D device created.\n");

	return hResult;
}