Browse Source

New Graphics APIs

    /// Returns the index of the display containing the center of the window on success or a negative error code on failure.
    int GetCurrentMonitor() const;
    /// Returns true if window is maximized or runs in full screen mode.
    bool GetMaximized() const;
    /// Raises window if it was minimized.
    void RaiseWindow() const;
    /// Return display dpi information: (hdpi, vdpi, ddpi). On failure returns zero vector.
    Vector3 GetDisplayDPI() const;
Rokas Kupstys 8 years ago
parent
commit
0b2ade9efb
2 changed files with 35 additions and 0 deletions
  1. 26 0
      Source/Urho3D/Graphics/Graphics.cpp
  2. 9 0
      Source/Urho3D/Graphics/Graphics.h

+ 26 - 0
Source/Urho3D/Graphics/Graphics.cpp

@@ -371,6 +371,32 @@ void Graphics::CreateWindowIcon()
     }
     }
 }
 }
 
 
+int Graphics::GetCurrentMonitor() const
+{
+    return SDL_GetWindowDisplayIndex((SDL_Window*) this->GetSDLWindow());
+}
+
+bool Graphics::GetMaximized() const
+{
+    if (!window_)
+        return false;
+
+    return SDL_GetWindowFlags(window_) & SDL_WINDOW_MAXIMIZED;
+}
+
+void Graphics::RaiseWindow() const
+{
+    if (window_)
+        SDL_RaiseWindow(window_);
+}
+
+Vector3 Graphics::GetDisplayDPI() const
+{
+    Vector3 result;
+    SDL_GetDisplayDPI(0, &result.z_, &result.x_, &result.y_);
+    return result;
+}
+
 void RegisterGraphicsLibrary(Context* context)
 void RegisterGraphicsLibrary(Context* context)
 {
 {
     Animation::RegisterObject(context);
     Animation::RegisterObject(context);

+ 9 - 0
Source/Urho3D/Graphics/Graphics.h

@@ -562,6 +562,15 @@ public:
     /// Return whether is using an OpenGL 3 context. Return always false on Direct3D9 & Direct3D11.
     /// Return whether is using an OpenGL 3 context. Return always false on Direct3D9 & Direct3D11.
     static bool GetGL3Support();
     static bool GetGL3Support();
 
 
+    /// Returns the index of the display containing the center of the window on success or a negative error code on failure.
+    int GetCurrentMonitor() const;
+    /// Returns true if window is maximized or runs in full screen mode.
+    bool GetMaximized() const;
+    /// Raises window if it was minimized.
+    void RaiseWindow() const;
+    /// Return display dpi information: (hdpi, vdpi, ddpi). On failure returns zero vector.
+    Vector3 GetDisplayDPI() const;
+
 private:
 private:
     /// Create the application window.
     /// Create the application window.
     bool OpenWindow(int width, int height, bool resizable, bool borderless);
     bool OpenWindow(int width, int height, bool resizable, bool borderless);