Explorar el Código

Added GetDesktopResolution() to Graphics.

Lasse Öörni hace 12 años
padre
commit
25c7aa53c3

+ 2 - 0
Docs/LuaScriptAPI.dox

@@ -1563,6 +1563,7 @@ Methods:
 - bool GetStreamOffsetSupport() const
 - bool GetStreamOffsetSupport() const
 - bool GetSRGBSupport() const
 - bool GetSRGBSupport() const
 - bool GetSRGBWriteSupport() const
 - bool GetSRGBWriteSupport() const
+- IntVector2 GetDesktopResolution() const
 - static unsigned GetRGBFormat()
 - static unsigned GetRGBFormat()
 
 
 Properties:
 Properties:
@@ -1592,6 +1593,7 @@ Properties:
 - bool streamOffsetSupport (readonly)
 - bool streamOffsetSupport (readonly)
 - bool sRGBSupport (readonly)
 - bool sRGBSupport (readonly)
 - bool sRGBWriteSupport (readonly)
 - bool sRGBWriteSupport (readonly)
+- IntVector2 desktopResolution (readonly)
 
 
 ### BiasParameters
 ### BiasParameters
 
 

+ 1 - 0
Docs/ScriptAPI.dox

@@ -3701,6 +3701,7 @@ Properties:
 - bool forceSM2
 - bool forceSM2
 - IntVector2[]@ resolutions (readonly)
 - IntVector2[]@ resolutions (readonly)
 - int[]@ multiSampleLevels (readonly)
 - int[]@ multiSampleLevels (readonly)
+- IntVector2 desktopResolution (readonly)
 
 
 
 
 ### Renderer
 ### Renderer

+ 7 - 0
Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -1853,6 +1853,13 @@ PODVector<int> Graphics::GetMultiSampleLevels() const
     return ret;
     return ret;
 }
 }
 
 
+IntVector2 Graphics::GetDesktopResolution() const
+{
+    SDL_DisplayMode mode;
+    SDL_GetDesktopDisplayMode(0, &mode);
+    return IntVector2(mode.w, mode.h);
+}
+
 unsigned Graphics::GetFormat(CompressedFormat format) const
 unsigned Graphics::GetFormat(CompressedFormat format) const
 {
 {
     switch (format)
     switch (format)

+ 2 - 0
Source/Engine/Graphics/Direct3D9/D3D9Graphics.h

@@ -268,6 +268,8 @@ public:
     PODVector<IntVector2> GetResolutions() const;
     PODVector<IntVector2> GetResolutions() const;
     /// Return supported multisampling levels.
     /// Return supported multisampling levels.
     PODVector<int> GetMultiSampleLevels() const;
     PODVector<int> GetMultiSampleLevels() const;
+    /// Return the desktop resolution.
+    IntVector2 GetDesktopResolution() const;
     /// Return hardware format for a compressed image format, or 0 if unsupported.
     /// Return hardware format for a compressed image format, or 0 if unsupported.
     unsigned GetFormat(CompressedFormat format) const;
     unsigned GetFormat(CompressedFormat format) const;
     /// Return vertex buffer by index.
     /// Return vertex buffer by index.

+ 8 - 1
Source/Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -1810,7 +1810,7 @@ bool Graphics::IsDeviceLost() const
     if (impl_->window_ && (SDL_GetWindowFlags(impl_->window_) & SDL_WINDOW_MINIMIZED) != 0)
     if (impl_->window_ && (SDL_GetWindowFlags(impl_->window_) & SDL_WINDOW_MINIMIZED) != 0)
         return true;
         return true;
     #endif
     #endif
-    
+
     return impl_->context_ == 0;
     return impl_->context_ == 0;
 }
 }
 
 
@@ -1864,6 +1864,13 @@ PODVector<int> Graphics::GetMultiSampleLevels() const
     return ret;
     return ret;
 }
 }
 
 
+IntVector2 Graphics::GetDesktopResolution() const
+{
+    SDL_DisplayMode mode;
+    SDL_GetDesktopDisplayMode(0, &mode);
+    return IntVector2(mode.w, mode.h);
+}
+
 unsigned Graphics::GetFormat(CompressedFormat format) const
 unsigned Graphics::GetFormat(CompressedFormat format) const
 {
 {
     switch (format)
     switch (format)

+ 2 - 0
Source/Engine/Graphics/OpenGL/OGLGraphics.h

@@ -277,6 +277,8 @@ public:
     PODVector<IntVector2> GetResolutions() const;
     PODVector<IntVector2> GetResolutions() const;
     /// Return supported multisampling levels.
     /// Return supported multisampling levels.
     PODVector<int> GetMultiSampleLevels() const;
     PODVector<int> GetMultiSampleLevels() const;
+    /// Return the desktop resolution.
+    IntVector2 GetDesktopResolution() const;
     /// Return hardware format for a compressed image format, or 0 if unsupported.
     /// Return hardware format for a compressed image format, or 0 if unsupported.
     unsigned GetFormat(CompressedFormat format) const;
     unsigned GetFormat(CompressedFormat format) const;
     /// Return vertex buffer by index.
     /// Return vertex buffer by index.

+ 1 - 0
Source/Engine/Script/GraphicsAPI.cpp

@@ -1209,6 +1209,7 @@ static void RegisterGraphics(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Graphics", "bool get_forceSM2() const", asMETHOD(Graphics, GetForceSM2), asCALL_THISCALL);
     engine->RegisterObjectMethod("Graphics", "bool get_forceSM2() const", asMETHOD(Graphics, GetForceSM2), asCALL_THISCALL);
     engine->RegisterObjectMethod("Graphics", "Array<IntVector2>@ get_resolutions() const", asFUNCTION(GraphicsGetResolutions), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Graphics", "Array<IntVector2>@ get_resolutions() const", asFUNCTION(GraphicsGetResolutions), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Graphics", "Array<int>@ get_multiSampleLevels() const", asFUNCTION(GraphicsGetMultiSampleLevels), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Graphics", "Array<int>@ get_multiSampleLevels() const", asFUNCTION(GraphicsGetMultiSampleLevels), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Graphics", "IntVector2 get_desktopResolution() const", asMETHOD(Graphics, GetDesktopResolution), asCALL_THISCALL);
     engine->RegisterGlobalFunction("Graphics@+ get_graphics()", asFUNCTION(GetGraphics), asCALL_CDECL);
     engine->RegisterGlobalFunction("Graphics@+ get_graphics()", asFUNCTION(GetGraphics), asCALL_CDECL);
 }
 }
 
 

+ 2 - 0
Source/Extras/LuaScript/pkgs/Graphics/Graphics.pkg

@@ -40,6 +40,7 @@ class Graphics : public Object
     bool GetStreamOffsetSupport() const;
     bool GetStreamOffsetSupport() const;
     bool GetSRGBSupport() const;
     bool GetSRGBSupport() const;
     bool GetSRGBWriteSupport() const;
     bool GetSRGBWriteSupport() const;
+    IntVector2 GetDesktopResolution() const;
     
     
     static unsigned GetRGBFormat();
     static unsigned GetRGBFormat();
     
     
@@ -68,4 +69,5 @@ class Graphics : public Object
     tolua_readonly tolua_property__get_set bool streamOffsetSupport;
     tolua_readonly tolua_property__get_set bool streamOffsetSupport;
     tolua_readonly tolua_property__get_set bool sRGBSupport;
     tolua_readonly tolua_property__get_set bool sRGBSupport;
     tolua_readonly tolua_property__get_set bool sRGBWriteSupport;
     tolua_readonly tolua_property__get_set bool sRGBWriteSupport;
+    tolua_readonly tolua_property__get_set IntVector2 desktopResolution;
 };
 };