Exemplo n.º 1
0
HRESULT CGraphics::Reset(void)
{
	m_NeedReset = FALSE;

	// If the device can be restored, the application prepares the 
	// device by destroying all video-memory resources and any 
	// swap chains
	if(FAILED(Invalidate()))
	{
		TRACE(TEXT("Error: Failed to invalidate device.\n"));
		return E_FAIL;
	}

	// Try to reset the device
	HRESULT hr = m_Device->Reset(&m_PresentParameters);
	if(FAILED(hr))
	{
		// Check if error other than device lost
		if(hr != D3DERR_DEVICELOST)
		{
			HWND hWnd = GetWindowHandle();
			UINT width = GetWidth();
			UINT height = GetHeight();
			BOOL blur = GetBlur();

			UninitializeRenderer();
			UninitializeDisplay();
			InitializeDisplay(hWnd,width,height,blur);
			InitializeRenderer();
			TRACE(TEXT("Warning: Failed to reset the display device, reinitialized graphics.\n"));
			return S_FALSE;
		}

		// The device was lost again, so continue waiting until it can be reset
		TRACE(TEXT("Error: Failed to reset the display device.\n"));
		return S_FALSE;
	}

	// Finally, a lost device must re-create resources (including  
	// video memory resources) after it has been reset
	if(FAILED(Restore()))
	{
		HWND hWnd = GetWindowHandle();
		UINT width = GetWidth();
		UINT height = GetHeight();
		BOOL blur = GetBlur();

		UninitializeRenderer();
		UninitializeDisplay();
		InitializeDisplay(hWnd,width,height,blur);
		InitializeRenderer();
		TRACE(TEXT("Warning: Failed to restore device, reinitialized graphics.\n"));
		return false;
	}

	return S_OK;
}
extern "C" void EXPORT_API HARMONY_SET_GRAPHICS_DEVICE_FUNC (void* device, int deviceType, int eventType)
{
  LOGI( "HarmonySetGraphicsDevice (device: '%p') (deviceType: '%i') (eventType: '%i')\n", device, deviceType, eventType );
  
  InitializeRenderer(deviceType);

  //  Update renderer device if available.
  if ( g_renderer )
  {
    g_renderer->setDevice( device, eventType );
  }
}
Exemplo n.º 3
0
void IVRendererNode::ReInitializeRenderer()
{
  if(!IsInitialized())
  {
    InitializeRenderer();
  }
  else
  {
    // Take care of deregistration and re-registration at the correct index
    VScopedRendererNodeDeinit lock(this);
  }
  m_RendererNodeHelper.InvalidateFrustum();
  Vision::Callbacks.OnReferenceContextChanged.TriggerCallbacks();
}
Exemplo n.º 4
0
void MQ2NavigationPlugin::Plugin_Initialize()
{
	if (m_initialized)
		return;

	HookStatus status = InitializeHooks();
	if (status != HookStatus::Success)
	{
		m_retryHooks = (status == HookStatus::MissingDevice);
		return;
	}

	mq2nav::LoadSettings();

	InitializeRenderer();

	AddModule<KeybindHandler>();
	AddModule<NavMeshLoader>();
	AddModule<ModelLoader>();
	AddModule<NavMeshRenderer>();
	AddModule<UiController>();

	for (const auto& m : m_modules)
	{
		m.second->Initialize();
	}

	// get the keybind handler and connect it to our keypress handler
	auto keybindHandler = Get<KeybindHandler>();
	m_keypressConn = keybindHandler->OnMovementKeyPressed.Connect(
		[this]() { OnMovementKeyPressed(); });

	// initialize mesh loader's settings
	auto meshLoader = Get<NavMeshLoader>();
	meshLoader->SetAutoReload(mq2nav::GetSettings().autoreload);

	m_initialized = true;

	Plugin_SetGameState(gGameState);

	AddCommand("/navigate", NavigateCommand);
	AddMQ2Data("Navigation", NavigateData);

	auto ui = Get<UiController>();
	m_updateTabConn = ui->OnTabUpdate.Connect([=](TabPage page) { OnUpdateTab(page); });
}
Exemplo n.º 5
0
// Initialize each member in turn. This is logically just one function, since
// the order of initialization cannot be changed. However, it's nice for
// debugging and readability to have each section lexographically separate.
bool Game::Initialize(const char* const binary_directory) {
  LogInfo("Zooshi Initializing...");
#if defined(BENCHMARK_MOTIVE)
  InitBenchmarks(10);
#endif  // defined(BENCHMARK_MOTIVE)

  input_.Initialize();
  input_.AddAppEventCallback(AudioEngineVolumeControl(&audio_engine_));
#ifdef ANDROID_HMD
  input_.head_mounted_display_input().EnableDeviceOrientationCorrection();
#endif  // ANDROID_HMD

  SystraceInit();

  if (!fplbase::ChangeToUpstreamDir(binary_directory, kAssetsDir)) return false;

  if (!LoadFile(kConfigFileName, &config_source_)) return false;

  if (!InitializeRenderer()) return false;

  if (!LoadFile(GetConfig().input_config()->c_str(), &input_config_source_))
    return false;

  if (!LoadFile(GetConfig().assets_filename()->c_str(),
                &asset_manifest_source_)) {
    return false;
  }
  const auto& asset_manifest = GetAssetManifest();

  if (!InitializeAssets()) return false;

  if (!audio_engine_.Initialize(GetConfig().audio_config()->c_str())) {
    return false;
  }
  audio_engine_.LoadSoundBank(asset_manifest.sound_bank()->c_str());
  audio_engine_.StartLoadingSoundFiles();

  InitializeBreadboardModules();

  for (size_t i = 0; i < asset_manifest.font_list()->size(); i++) {
    flatbuffers::uoffset_t index = static_cast<flatbuffers::uoffset_t>(i);
    font_manager_.Open(asset_manifest.font_list()->Get(index)->c_str());
  }
  font_manager_.SetRenderer(renderer_);

  SetPerformanceMode(fplbase::kHighPerformance);

  scene_lab_.reset(new scene_lab::SceneLab());

  world_.Initialize(GetConfig(), &input_, &asset_manager_, &world_renderer_,
                    &font_manager_, &audio_engine_, &graph_factory_, &renderer_,
                    scene_lab_.get());

#ifdef __ANDROID__
  if (fplbase::SupportsHeadMountedDisplay()) {
    BasePlayerController* controller = new AndroidCardboardController();
    controller->set_input_config(&GetInputConfig());
    controller->set_input_system(&input_);
    controller->set_enabled(ZOOSHI_FORCE_ONSCREEN_CONTROLLER == 0);
    world_.AddController(controller);
    world_.hmd_controller = controller;
  }
#endif  // __ANDROID__

// If this is a mobile platform or the onscreen controller is forced on
// instance the onscreen controller.
#if defined(PLATFORM_MOBILE) || ZOOSHI_FORCE_ONSCREEN_CONTROLLER
  {
    OnscreenController* onscreen_controller = new OnscreenController();
    onscreen_controller->set_input_config(&GetInputConfig());
    onscreen_controller->set_input_system(&input_);
    onscreen_controller->set_enabled(!fplbase::SupportsHeadMountedDisplay() ||
                                     ZOOSHI_FORCE_ONSCREEN_CONTROLLER);
    world_.AddController(onscreen_controller);
    world_.onscreen_controller_ui.set_controller(onscreen_controller);
#ifdef ANDROID_HMD
    world_.onscreen_controller = onscreen_controller;
#endif  // ANDROID_HMD
  }
#endif  // defined(PLATFORM_MOBILE) || ZOOSHI_FORCE_ONSCREEN_CONTROLLER

// If this is a desktop platform and we're not forcing the onscreen controller
// instance the mouse controller.
#if !defined(PLATFORM_MOBILE) && !ZOOSHI_FORCE_ONSCREEN_CONTROLLER
  {
    BasePlayerController* controller = new MouseController();
    controller->set_input_config(&GetInputConfig());
    controller->set_input_system(&input_);
    world_.AddController(controller);
  }
#endif  // !ZOOSHI_FORCE_ONSCREEN_CONTROLLER && !defined(PLATFORM_MOBILE)

#ifdef ANDROID_GAMEPAD
  {
    GamepadController* controller = new GamepadController();
    controller->set_input_config(&GetInputConfig());
    controller->set_input_system(&input_);
    world_.AddController(controller);
  }
#endif  // ANDROID_GAMEPAD

  world_renderer_.Initialize(&world_);

  scene_lab_->Initialize(GetConfig().scene_lab_config(), &world_.entity_manager,
                         &font_manager_);

  scene_lab_->AddComponentToUpdate(
      corgi::component_library::TransformComponent::GetComponentId());
  scene_lab_->AddComponentToUpdate(ShadowControllerComponent::GetComponentId());
  scene_lab_->AddComponentToUpdate(
      corgi::component_library::RenderMeshComponent::GetComponentId());

  gpg_manager_.Initialize(false);

  auto fader_material =
      asset_manager_.FindMaterial(asset_manifest.fader_material()->c_str());
  assert(fader_material);
  fader_.Init(fader_material, shader_textured_);

  const Config* config = &GetConfig();
  loading_state_.Initialize(&input_, &world_, asset_manifest, &asset_manager_,
                            &audio_engine_, shader_textured_, &fader_);
  pause_state_.Initialize(&input_, &world_, config, &asset_manager_,
                          &font_manager_, &audio_engine_);
  gameplay_state_.Initialize(&input_, &world_, config, &GetInputConfig(),
                             &world_.entity_manager, scene_lab_.get(),
                             &gpg_manager_, &audio_engine_, &fader_);
  game_menu_state_.Initialize(&input_, &world_, config, &asset_manager_,
                              &font_manager_, &GetAssetManifest(),
                              &gpg_manager_, &audio_engine_, &fader_);
  game_over_state_.Initialize(&input_, &world_, config, &asset_manager_,
                              &font_manager_, &gpg_manager_, &audio_engine_);
  intro_state_.Initialize(&input_, &world_, config, &fader_, &audio_engine_);
  scene_lab_state_.Initialize(&renderer_, &input_, scene_lab_.get(), &world_);

  state_machine_.AssignState(kGameStateLoading, &loading_state_);
  state_machine_.AssignState(kGameStateGameplay, &gameplay_state_);
  state_machine_.AssignState(kGameStatePause, &pause_state_);
  state_machine_.AssignState(kGameStateGameMenu, &game_menu_state_);
  state_machine_.AssignState(kGameStateIntro, &intro_state_);
  state_machine_.AssignState(kGameStateGameOver, &game_over_state_);
  state_machine_.AssignState(kGameStateSceneLab, &scene_lab_state_);
  state_machine_.SetCurrentStateId(kGameStateLoading);

#ifdef ANDROID_HMD
  if (fplbase::AndroidGetActivityName() ==
      "com.google.fpl.zooshi.ZooshiHmdActivity") {
    world_.SetIsInCardboard(true);
  }
#endif  // ANDROID_HMD

  LogInfo("Initialization complete\n");
  return true;
}
Exemplo n.º 6
0
// ****************************************************************************
// ****************************************************************************
void Initialize(ID3D11Device* dev, ID3D11DeviceContext *context, IDXGISwapChain *swapChain)
{
	InitializeRenderer(dev,context, swapChain);


}