/// <summary>
    /// Constructor.  Pass in an enumeration and the current D3D settings.
    /// </summary>
    public D3DSettingsForm(D3DEnumeration enumerationParam, D3DSettings settingsParam)
    {
      enumeration = enumerationParam;
      settings = settingsParam.Clone();

      // Required for Windows Form Designer support
      InitializeComponent();

      // Fill adapter combo box.  Updating the selected adapter will trigger
      // updates of the rest of the dialog.
      foreach (GraphicsAdapterInfo adapterInfo in enumeration.AdapterInfoList)
      {
        adapterComboBox.Items.Add(adapterInfo);
        if (adapterInfo.AdapterOrdinal == settings.AdapterOrdinal)
        {
          adapterComboBox.SelectedItem = adapterInfo;
        }
      }
      if (adapterComboBox.SelectedItem == null && adapterComboBox.Items.Count > 0)
      {
        adapterComboBox.SelectedIndex = 0;
      }
    }
Example #2
0
    /// <summary>
    /// Init graphics device
    /// </summary>
    /// <returns>true if a good device was found, false otherwise</returns>
    /// 
    protected bool Init()
    {
      Log.Debug("D3D: Init()");

      // Reset Adapter
      AdapterInfo = null;

      // log information about available adapters
      var enumeration = new D3DEnumeration();
      enumeration.Enumerate();
      foreach (GraphicsAdapterInfo ai in enumeration.AdapterInfoList)
      {
        Log.Debug("D3D: Init Adapter #{0}: {1} - Driver: {2} ({3}) - DeviceName: {4}",
          ai.AdapterOrdinal, ai.AdapterDetails.Description, ai.AdapterDetails.DriverName, ai.AdapterDetails.DriverVersion, ai.AdapterDetails.DeviceName);
      }

      // Set up cursor
      _renderTarget.Cursor = Cursors.Default;

      // if our render target is the main window and we haven't said ignore the menus, add our menu
      if (Windowed)
      {
        Menu = _menuStripMain;
      }

      // Initialize the application timer
      DXUtil.Timer(DirectXTimer.Start);

      int adapIntCount = 0;

      // get display adapter info
      OnEnumeration();

      // Reset counter
      adapIntCount = 0;

      while (AdapterInfo == null && adapIntCount < numberOfRetriesAdaptor)
      {
        try
        {
          Log.Debug("D3D: Starting and find Adapter info - retry #{0}", adapIntCount);
          adapIntCount++;
          AdapterInfo = FindAdapterForScreen(GUIGraphicsContext.currentScreen);
          if (AdapterInfo == null)
          {
            OnEnumeration();
          }
          if (AdapterInfo != null)
          {
            Log.Debug("D3D: Starting and find Adapter #{0}: {1} - retry #{2}", AdapterInfo.AdapterOrdinal, AdapterInfo, adapIntCount);
          }
          else
          {
            Log.Debug("D3D: Adapter info is not detected - retry #{0}", adapIntCount);
          }
        }
        catch (Exception ex)
        {
          Log.Error("D3D: Starting and find AdapterInfo exception {0}", ex);
          AdapterInfo = null;
        }
      }

      if (!Windowed)
      {
        Log.Info("D3D: Starting in full screen");

        if (AutoHideTaskbar && !MinimizeOnStartup)
        {
          HideTaskBar(true);
        }
        
        FormBorderStyle = FormBorderStyle.None;
        MaximizeBox     = false;
        MinimizeBox     = false;
        Menu            = null;

        var newBounds  = GUIGraphicsContext.currentScreen.Bounds;
        Bounds         = newBounds;
        ClientSize     = newBounds.Size;
        Log.Info("D3D: Client size: {0}x{1} - Screen: {2}x{3}",
                 ClientSize.Width, ClientSize.Height,
                 GUIGraphicsContext.currentScreen.Bounds.Width, GUIGraphicsContext.currentScreen.Bounds.Height);
      }

      // Backup bounds when native resolution is not (1024x768)
      if (GUIGraphicsContext.currentScreen.Bounds.Width != 1024 &&
          GUIGraphicsContext.currentScreen.Bounds.Height != 768)
      {
        Log.Debug("D3D: backups screen Bounds {0}", Bounds);
        _backupBounds = GUIGraphicsContext.currentScreen.Bounds;
        _backupscreen = GUIGraphicsContext.currentScreen;
      }

      if (!successful)
      {
        // Initialize D3D Device
        InitializeDevice();
      }

      return true;
    }
Example #3
0
    /// <summary>
    /// 
    /// </summary>
    protected virtual void OnEnumeration()
    {
      _enumerationSettings = new D3DEnumeration();
      int enumIntCount = 0;
      bool ConfirmDeviceCheck = false;

      // get display adapter info
      while (ConfirmDeviceCheck != true && enumIntCount < numberOfRetriesEnum)
      {
        try
        {
          Log.Debug("D3D: Starting and find Enumeration Settings - retry {0}", enumIntCount);
          _enumerationSettings.ConfirmDeviceCallback = ConfirmDevice;
          try
          {
            _enumerationSettings.Enumerate();
            ConfirmDeviceCheck = true;
          }
          catch (Exception ex)
          {
            Log.Error("D3D: failed to _enumerationSettings exception {0}", ex);
            _enumerationSettings = new D3DEnumeration();
          }
        }
        catch (Exception ex)
        {
          Log.Error("D3D: Starting and find _enumerationSettings exception {0}", ex);
          _enumerationSettings = new D3DEnumeration();
        }
        enumIntCount++;
      }
    }
Example #4
0
    protected static Rectangle         _backupBounds;             // Bounds backup

    #endregion

    #region constructor

    /// <summary>
    /// Constructor
    /// </summary>
    protected D3D()
    {
      _firstTimeWindowDisplayed  = true;
      _firstTimeActivated       = true;
      MinimizeOnStartup         = false;
      MinimizeOnGuiExit         = false;
      MinimizeOnFocusLoss       = false;
      ShuttingDown              = false;
      AutoHideMouse             = true;
      MouseCursor               = true;
      Windowed                  = true;
      Volume                    = -1;
      AppActive                 = false;
      KeyPreview                = true;
      Frames                    = 0;
      FrameStatsLine1           = null;
      FrameStatsLine2           = null;
      Text                      = Resources.D3DApp_NotifyIcon_MediaPortal;
      PlaylistPlayer            = PlayListPlayer.SingletonPlayer;
      MouseTimeOutTimer         = DateTime.Now;
      _lastActiveWindow         = -1;
      IsVisible                 = true;
      IsDisplayTurnedOn         = true;
      IsInAwayMode              = false;
      IsUserPresent             = true;
      _lastMouseCursor          = !MouseCursor;
      _showCursorWhenFullscreen = false;
      _currentPlayListType      = PlayListType.PLAYLIST_NONE;
      _enumerationSettings      = new D3DEnumeration();
      _presentParams            = new PresentParameters();
      _renderTarget             = this;

      using (Settings xmlreader = new MPSettings())
      {
        _useExclusiveDirectXMode = xmlreader.GetValueAsBool("general", "exclusivemode", true);
        UseEnhancedVideoRenderer = xmlreader.GetValueAsBool("general", "useEVRenderer", false);
        _disableMouseEvents      = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false);
        AutoHideTaskbar          = xmlreader.GetValueAsBool("general", "hidetaskbar", true);
        _alwaysOnTop             = xmlreader.GetValueAsBool("general", "alwaysontop", false);
        _reduceFrameRate         = xmlreader.GetValueAsBool("gui", "reduceframerate", false);
        _doNotWaitForVSync       = xmlreader.GetValueAsBool("debug", "donotwaitforvsync", false);
      }

      _useExclusiveDirectXMode = !UseEnhancedVideoRenderer && _useExclusiveDirectXMode;
      GUIGraphicsContext.IsVMR9Exclusive = _useExclusiveDirectXMode;
      GUIGraphicsContext.IsEvr = UseEnhancedVideoRenderer;
      
      InitializeComponent();
    }