Beispiel #1
0
bool CD3D_Device::SetMode(D3DModeInfo* pMode)
{
	D3DPRESENT_PARAMETERS PresentationParam;
	SetPresentationParams(PresentationParam,pMode);
	if (m_pD3DDevice->Reset(&PresentationParam) != D3D_OK) return false;
	return true;
}
Beispiel #2
0
void CGSH_OpenGLAndroid::SetupContext()
{
	if(m_surface != EGL_NO_SURFACE)
	{
		eglDestroySurface(m_display, m_surface);
		m_surface = EGL_NO_SURFACE;
	}
	
	m_surface = eglCreateWindowSurface(m_display, m_config, m_window, NULL);
	assert(m_surface != EGL_NO_SURFACE);
	
	auto makeCurrentResult = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
	assert(makeCurrentResult != EGL_FALSE);
	
	{
		GLint w = 0, h = 0;
		eglQuerySurface(m_display, m_surface, EGL_WIDTH, &w);
		eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &h);
		
		PRESENTATION_PARAMS presentationParams;
		presentationParams.mode 			= PRESENTATION_MODE_FIT;
		presentationParams.windowWidth 		= w;
		presentationParams.windowHeight 	= h;

		SetPresentationParams(presentationParams);
	}
}
Beispiel #3
0
bool CD3D_Device::SetMode(D3DModeInfo* pMode)
{
	D3DPRESENT_PARAMETERS PresentationParam;
	SetPresentationParams(PresentationParam,pMode);
	HRESULT hResetResult = m_pD3DDevice->Reset(&PresentationParam);
	if (!SUCCEEDED(hResetResult))
	{
		// Wait for a couple seconds to see if it'll come back...
		uint32 nMaxWait = 20;
		do
		{
			Sleep(100);
			hResetResult = m_pD3DDevice->TestCooperativeLevel();
		} while ((hResetResult == D3DERR_DEVICELOST) && (nMaxWait--));
		// Now try and reset again.
		if (m_pD3DDevice->Reset(&PresentationParam) != D3D_OK)
		{
			// Fall back and try to reset
			TryFallingBack_OnFailedDevCreate(&PresentationParam);
			if (m_pD3DDevice->Reset(&PresentationParam) != D3D_OK)
			{
				return false;
			}
		}
	}

	// Reset the device caps, since some of them are specific to the screen mode
	PreCalcSomeDeviceCaps();

	m_rcViewport.left			= 0;	// Force a viewport reset...
	m_rcViewport.right			= 0;
	m_rcViewport.top			= 0;
	m_rcViewport.bottom			= 0;
	return true;
}
Beispiel #4
0
// Create the Sucka...
bool CD3D_Device::CreateDevice(D3DAdapterInfo* pAdapter,D3DDeviceInfo* pDevice,D3DModeInfo* pMode)
{
	if (!TdGuard::Aegis::GetSingleton().DoWork())
	{
		return false;
	}


	FreeDevice();								// Make sure it's all released and groovie...

	m_pAdapter	= pAdapter;						// Initialization...
	m_pDevice	= pDevice;
	m_pMode		= pMode;

	// Create the sucka...
	uint32 BehaviorFlags = D3DCREATE_MULTITHREADED;
	if (pDevice->d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) 
	{
		BehaviorFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
	}
	else 
	{
		BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
	}

	D3DPRESENT_PARAMETERS PresentationParam;
	SetPresentationParams(PresentationParam,pMode);
	HRESULT hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd_RenderWindow,BehaviorFlags,&PresentationParam,&m_pD3DDevice);
	if ((hResult != D3D_OK) || !m_pD3DDevice) 
	{	// Give it more more try - Presentation params might have been changed by D3D to something acceptable...
		OutputDebugString("Warning: Create failed. Attempting to fall back...\n");
		TryFallingBack_OnFailedDevCreate(&PresentationParam);

		hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd_RenderWindow,BehaviorFlags,&PresentationParam,&m_pD3DDevice);

		if ((hResult != D3D_OK) || !m_pD3DDevice) 
		{ 
			FreeAll(); 
			return false; 
		} 
	}

	if (FAILED(m_pD3DDevice->GetDeviceCaps(&m_DeviceCaps)))	
	{ 
		FreeAll(); 
		return false; 
	}

	SetDefaultRenderStates();					// Set the default render states...
	PreCalcSomeDeviceCaps();					// Do some precalcing of device caps (figure out if we can do some puff)...

	// Display a warning message
//	if (m_pDevice->DeviceType == D3DDEVTYPE_REF) AddDebugMessage(1,"Warning: Couldnt' find any HAL devices, Using reference rasterizer");

	return true;
}
Beispiel #5
0
// Create the Sucka...
bool CD3D_Device::CreateDevice(D3DAdapterInfo* pAdapter,D3DDeviceInfo* pDevice,D3DModeInfo* pMode)
{
	FreeDevice();								// Make sure it's all released and groovie...

	m_pAdapter	= pAdapter;						// Initialization...
	m_pDevice	= pDevice;
	m_pMode		= pMode;

	// Create the sucka...
 	uint32 BehaviorFlags = D3DCREATE_MULTITHREADED;

	if (pDevice->d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
		BehaviorFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
	else
		BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	D3DPRESENT_PARAMETERS PresentationParam;
	SetPresentationParams(PresentationParam,pMode);
	IDirect3DDevice9 *pD3DDevice;
	HRESULT hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd,BehaviorFlags,&PresentationParam,&pD3DDevice);
	if ((hResult != D3D_OK) || !pD3DDevice)
	{
		// Give it more more try - Presentation params might have been changed by D3D to something acceptable...
		OUTPUT_D3D_ERROR(1,hResult);			// Report the error...
		OutputDebugString("Warning: Create failed. Attempting to fall back...\n");
		TryFallingBack_OnFailedDevCreate(&PresentationParam);
		hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd,BehaviorFlags,&PresentationParam,&pD3DDevice);
		if ((hResult != D3D_OK) || !pD3DDevice)
		{
			OUTPUT_D3D_ERROR(0,hResult); FreeDevice(); return false;
		}
	}

	// Create our wrapper, which we're going to present to the world as an actual D3D device
	LT_MEM_TRACK_ALLOC(m_pD3DDevice = new CDirect3DDevice9Wrapper,LT_MEM_TYPE_RENDERER);
	m_pD3DDevice->SetDevice(pD3DDevice);

	if (FAILED(m_pD3DDevice->GetDeviceCaps(&m_DeviceCaps)))
	{
		FreeDevice();
		return false;
	}

	SetDefaultRenderStates();					// Set the default render states...
	PreCalcSomeDeviceCaps();					// Do some precalcing of device caps (figure out if we can do some puff)...

	m_pD3DDevice->SetStates();

	// Display a warning message
	if (m_pDevice->DeviceType == D3DDEVTYPE_REF)
		AddDebugMessage(1,"Warning: Couldn\'t find any HAL devices, Using reference rasterizer");

	//make sure to clear out the back buffer so it isn't filled with left over garbage
	LTRGBColor ClearColor;
	ClearColor.dwordVal = 0;

	d3d_Clear(NULL, CLEARSCREEN_SCREEN | CLEARSCREEN_RENDER, ClearColor);

	//create the end of frame query events
	PD3DDEVICE->CreateQuery(D3DQUERYTYPE_EVENT, &m_pEndOfFrameQuery);

	// Initialize the render target manager.
	CRenderTargetMgr::GetSingleton().Init();

	return true;
}