예제 #1
0
bool WindowsHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
	WindowsGraphicsContext *graphicsContext = nullptr;
	switch (g_Config.iGPUBackend) {
	case GPU_BACKEND_OPENGL:
		graphicsContext = new WindowsGLContext();
		break;
	case GPU_BACKEND_DIRECT3D9:
		graphicsContext = new D3D9Context();
		break;
	case GPU_BACKEND_DIRECT3D11:
		graphicsContext = new D3D11Context();
		break;
	case GPU_BACKEND_VULKAN:
		graphicsContext = new WindowsVulkanContext();
		break;
	default:
		return false;
	}

	if (graphicsContext->Init(hInstance_, displayWindow_, error_message)) {
		*ctx = graphicsContext;
		gfx_ = graphicsContext;
		return true;
	} else {
		delete graphicsContext;
		*ctx = nullptr;
		gfx_ = nullptr;
		return false;
	}
}
예제 #2
0
bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
	hWnd = CreateHiddenWindow();

	if (WINDOW_VISIBLE) {
		ShowWindow(hWnd, TRUE);
		SetFocus(hWnd);
	}

	WindowsGraphicsContext *graphicsContext = nullptr;
	switch (gpuCore_) {
	case GPU_NULL:
	case GPU_GLES:
	case GPU_SOFTWARE:
		graphicsContext = new WindowsGLContext();
		break;

	case GPU_DIRECTX9:
		graphicsContext = new D3D9Context();
		break;

	case GPU_DIRECTX11:
		return false;

	case GPU_VULKAN:
		graphicsContext = new WindowsVulkanContext();
		break;
	}

	if (graphicsContext->Init(NULL, hWnd, error_message)) {
		*ctx = graphicsContext;
		gfx_ = graphicsContext;
	} else {
		delete graphicsContext;
		*ctx = nullptr;
		gfx_ = nullptr;
		return false;
	}

	if (gpuCore_ == GPU_GLES) {
		// TODO: Do we need to do this here?
		CheckGLExtensions();
	}

	LoadNativeAssets();

	return true;
}