Browse Source

update script API for ShadowQuality

Xavier Maupeu 10 years ago
parent
commit
362242bd3b

+ 4 - 4
Source/Samples/Sample.inl

@@ -283,10 +283,10 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         // Shadow depth and filtering quality
         // Shadow depth and filtering quality
         else if (key == '6')
         else if (key == '6')
         {
         {
-            int quality = renderer->GetShadowQuality();
-            ++quality;
-            if (quality > SHADOWQUALITY_HIGH_24BIT)
-                quality = SHADOWQUALITY_LOW_16BIT;
+            ShadowQuality quality = renderer->GetShadowQuality();
+            quality = static_cast<ShadowQuality>(quality + 1);
+            if (quality > SHADOWQUALITY_BLUR_VSM)
+                quality = SHADOWQUALITY_SIMPLE_16BIT;
             renderer->SetShadowQuality(quality);
             renderer->SetShadowQuality(quality);
         }
         }
 
 

+ 1 - 1
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1713,7 +1713,7 @@ static void RegisterRenderer(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Renderer", "bool get_drawShadows() const", asMETHOD(Renderer, GetDrawShadows), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "bool get_drawShadows() const", asMETHOD(Renderer, GetDrawShadows), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "void set_shadowMapSize(int)", asMETHOD(Renderer, SetShadowMapSize), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "void set_shadowMapSize(int)", asMETHOD(Renderer, SetShadowMapSize), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_shadowMapSize() const", asMETHOD(Renderer, GetShadowMapSize), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_shadowMapSize() const", asMETHOD(Renderer, GetShadowMapSize), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Renderer", "void set_shadowQuality(int)", asMETHOD(Renderer, SetShadowQuality), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Renderer", "void set_shadowQuality(ShadowQuality)", asMETHOD(Renderer, SetShadowQuality), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_shadowQuality() const", asMETHOD(Renderer, GetShadowQuality), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_shadowQuality() const", asMETHOD(Renderer, GetShadowQuality), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "void set_maxShadowMaps(int)", asMETHOD(Renderer, SetMaxShadowMaps), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "void set_maxShadowMaps(int)", asMETHOD(Renderer, SetMaxShadowMaps), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_maxShadowMaps() const", asMETHOD(Renderer, GetMaxShadowMaps), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "int get_maxShadowMaps() const", asMETHOD(Renderer, GetMaxShadowMaps), asCALL_THISCALL);

+ 0 - 5
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -342,11 +342,6 @@ static const int QUALITY_MEDIUM = 1;
 static const int QUALITY_HIGH = 2;
 static const int QUALITY_HIGH = 2;
 static const int QUALITY_MAX = 15;
 static const int QUALITY_MAX = 15;
 
 
-/*static const int SHADOWQUALITY_LOW = 0;
-static const int SHADOWQUALITY_LOW_24BIT = 1;
-static const int SHADOWQUALITY_HIGH_16BIT = 2;
-static const int SHADOWQUALITY_HIGH_24BIT = 3;*/
-
 static const unsigned CLEAR_COLOR = 0x1;
 static const unsigned CLEAR_COLOR = 0x1;
 static const unsigned CLEAR_DEPTH = 0x2;
 static const unsigned CLEAR_DEPTH = 0x2;
 static const unsigned CLEAR_STENCIL = 0x4;
 static const unsigned CLEAR_STENCIL = 0x4;

+ 1 - 2
Source/Urho3D/Graphics/Renderer.cpp

@@ -1797,8 +1797,6 @@ void Renderer::ResetBuffers()
 
 
 String Renderer::GetShadowVariations() const
 String Renderer::GetShadowVariations() const
 {
 {
-    String result;
-
     switch (shadowQuality_)
     switch (shadowQuality_)
     {
     {
         case SHADOWQUALITY_SIMPLE_16BIT:
         case SHADOWQUALITY_SIMPLE_16BIT:
@@ -1822,6 +1820,7 @@ String Renderer::GetShadowVariations() const
         case SHADOWQUALITY_BLUR_VSM:
         case SHADOWQUALITY_BLUR_VSM:
             return "VSM_SHADOW ";
             return "VSM_SHADOW ";
     }
     }
+    return "";
 };
 };
 
 
 void Renderer::HandleScreenMode(StringHash eventType, VariantMap& eventData)
 void Renderer::HandleScreenMode(StringHash eventType, VariantMap& eventData)

+ 1 - 1
Source/Urho3D/Graphics/Renderer.h

@@ -242,7 +242,7 @@ public:
     int GetShadowMapSize() const { return shadowMapSize_; }
     int GetShadowMapSize() const { return shadowMapSize_; }
 
 
     /// Return shadow quality.
     /// Return shadow quality.
-    int GetShadowQuality() const { return shadowQuality_; }
+    ShadowQuality GetShadowQuality() const { return shadowQuality_; }
 
 
     /// Return whether shadow maps are reused.
     /// Return whether shadow maps are reused.
     bool GetReuseShadowMaps() const { return reuseShadowMaps_; }
     bool GetReuseShadowMaps() const { return reuseShadowMaps_; }

+ 12 - 5
Source/Urho3D/LuaScript/pkgs/Graphics/GraphicsDefs.pkg

@@ -176,16 +176,23 @@ enum FaceCameraMode
     FC_LOOKAT_Y
     FC_LOOKAT_Y
 };
 };
 
 
+/// Shadow type
+enum ShadowQuality
+{
+    SHADOWQUALITY_SIMPLE_16BIT = 0,
+    SHADOWQUALITY_SIMPLE_24BIT,
+    SHADOWQUALITY_PCF_16BIT,
+    SHADOWQUALITY_PCF_24BIT,
+    SHADOWQUALITY_VSM,
+    SHADOWQUALITY_BLUR_VSM
+};
+
+
 static const int QUALITY_LOW;
 static const int QUALITY_LOW;
 static const int QUALITY_MEDIUM;
 static const int QUALITY_MEDIUM;
 static const int QUALITY_HIGH;
 static const int QUALITY_HIGH;
 static const int QUALITY_MAX;
 static const int QUALITY_MAX;
 
 
-static const int SHADOWQUALITY_LOW_16BIT;
-static const int SHADOWQUALITY_LOW_24BIT;
-static const int SHADOWQUALITY_HIGH_16BIT;
-static const int SHADOWQUALITY_HIGH_24BIT;
-
 static const unsigned CLEAR_COLOR;
 static const unsigned CLEAR_COLOR;
 static const unsigned CLEAR_DEPTH;
 static const unsigned CLEAR_DEPTH;
 static const unsigned CLEAR_STENCIL;
 static const unsigned CLEAR_STENCIL;

+ 3 - 3
Source/Urho3D/LuaScript/pkgs/Graphics/Renderer.pkg

@@ -14,7 +14,7 @@ class Renderer
     void SetMaterialQuality(int quality);
     void SetMaterialQuality(int quality);
     void SetDrawShadows(bool enable);
     void SetDrawShadows(bool enable);
     void SetShadowMapSize(int size);
     void SetShadowMapSize(int size);
-    void SetShadowQuality(int quality);
+    void SetShadowQuality(ShadowQuality quality);
     void SetReuseShadowMaps(bool enable);
     void SetReuseShadowMaps(bool enable);
     void SetMaxShadowMaps(int shadowMaps);
     void SetMaxShadowMaps(int shadowMaps);
     void SetDynamicInstancing(bool enable);
     void SetDynamicInstancing(bool enable);
@@ -39,7 +39,7 @@ class Renderer
     int GetTextureQuality() const;
     int GetTextureQuality() const;
     int GetMaterialQuality() const;
     int GetMaterialQuality() const;
     int GetShadowMapSize() const;
     int GetShadowMapSize() const;
-    int GetShadowQuality() const;
+    ShadowQuality GetShadowQuality() const;
     bool GetReuseShadowMaps() const;
     bool GetReuseShadowMaps() const;
     int GetMaxShadowMaps() const;
     int GetMaxShadowMaps() const;
     bool GetDynamicInstancing() const;
     bool GetDynamicInstancing() const;
@@ -75,7 +75,7 @@ class Renderer
     tolua_property__get_set int textureQuality;
     tolua_property__get_set int textureQuality;
     tolua_property__get_set int materialQuality;
     tolua_property__get_set int materialQuality;
     tolua_property__get_set int shadowMapSize;
     tolua_property__get_set int shadowMapSize;
-    tolua_property__get_set int shadowQuality;
+    tolua_property__get_set ShadowQuality shadowQuality;
     tolua_property__get_set bool reuseShadowMaps;
     tolua_property__get_set bool reuseShadowMaps;
     tolua_property__get_set int maxShadowMaps;
     tolua_property__get_set int maxShadowMaps;
     tolua_property__get_set bool dynamicInstancing;
     tolua_property__get_set bool dynamicInstancing;