Kaynağa Gözat

Merge pull request #1088 from rcmaniac25/helpful-additions-stencil

Stencil test bug fix and lua bindings
Sean Paul Taylor 12 yıl önce
ebeveyn
işleme
37af38240a

+ 1 - 1
CMakeLists.txt

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
 
 project(GamePlay)
 
-set(GAMEPLAY_VERSION 1.6.0)
+set(GAMEPLAY_VERSION 1.7.0)
 set(CMAKE_C_COMPILER_INIT g++)
 
 # debug

+ 4 - 0
gameplay/CMakeLists.txt

@@ -497,6 +497,10 @@ set(GAMEPLAY_LUA
     src/lua/lua_RenderStateDepthFunction.h
     src/lua/lua_RenderStateStateBlock.cpp
     src/lua/lua_RenderStateStateBlock.h
+    src/lua/lua_RenderStateStencilFunction.cpp
+    src/lua/lua_RenderStateStencilFunction.h
+    src/lua/lua_RenderStateStencilOperation.cpp
+    src/lua/lua_RenderStateStencilOperation.h
     src/lua/lua_RenderTarget.cpp
     src/lua/lua_RenderTarget.h
     src/lua/lua_Scene.cpp

+ 3 - 1
gameplay/android/jni/Android.mk

@@ -41,7 +41,7 @@ LOCAL_SRC_FILES := \
     Gamepad.cpp \
     HeightField.cpp \
     Image.cpp \
-	ImageControl.cpp \
+    ImageControl.cpp \
     Joint.cpp \
     Joystick.cpp \
     Label.cpp \
@@ -240,6 +240,8 @@ LOCAL_SRC_FILES := \
     lua/lua_RenderStateCullFaceSide.cpp \
     lua/lua_RenderStateDepthFunction.cpp \
     lua/lua_RenderStateStateBlock.cpp \
+    lua/lua_RenderStateStencilFunction.cpp \
+    lua/lua_RenderStateStencilOperation.cpp \
     lua/lua_RenderTarget.cpp \
     lua/lua_Scene.cpp \
     lua/lua_SceneDebugFlags.cpp \

+ 4 - 0
gameplay/gameplay.vcxproj

@@ -232,6 +232,8 @@
     <ClCompile Include="src\lua\lua_RenderStateCullFaceSide.cpp" />
     <ClCompile Include="src\lua\lua_RenderStateDepthFunction.cpp" />
     <ClCompile Include="src\lua\lua_RenderStateStateBlock.cpp" />
+    <ClCompile Include="src\lua\lua_RenderStateStencilFunction.cpp" />
+    <ClCompile Include="src\lua\lua_RenderStateStencilOperation.cpp" />
     <ClCompile Include="src\lua\lua_RenderTarget.cpp" />
     <ClCompile Include="src\lua\lua_Scene.cpp" />
     <ClCompile Include="src\lua\lua_SceneDebugFlags.cpp" />
@@ -514,6 +516,8 @@
     <ClInclude Include="src\lua\lua_RenderStateCullFaceSide.h" />
     <ClInclude Include="src\lua\lua_RenderStateDepthFunction.h" />
     <ClInclude Include="src\lua\lua_RenderStateStateBlock.h" />
+    <ClInclude Include="src\lua\lua_RenderStateStencilFunction.h" />
+    <ClInclude Include="src\lua\lua_RenderStateStencilOperation.h" />
     <ClInclude Include="src\lua\lua_RenderTarget.h" />
     <ClInclude Include="src\lua\lua_Scene.h" />
     <ClInclude Include="src\lua\lua_SceneDebugFlags.h" />

+ 12 - 0
gameplay/gameplay.vcxproj.filters

@@ -855,6 +855,12 @@
     <ClCompile Include="src\lua\lua_TextBoxInputMode.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
+    <ClCompile Include="src\lua\lua_RenderStateStencilFunction.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
+    <ClCompile Include="src\lua\lua_RenderStateStencilOperation.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\Animation.h">
@@ -1697,6 +1703,12 @@
     <ClInclude Include="src\lua\lua_TextBoxInputMode.h">
       <Filter>src\lua</Filter>
     </ClInclude>
+    <ClInclude Include="src\lua\lua_RenderStateStencilFunction.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
+    <ClInclude Include="src\lua\lua_RenderStateStencilOperation.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="src\Game.inl">

+ 1 - 1
gameplay/src/RenderState.cpp

@@ -695,7 +695,7 @@ void RenderState::StateBlock::restore(long stateOverrideBits)
     {
 		GL_ASSERT( glStencilMask(RS_ALL_ONES) );
         _defaultState->_bits &= ~RS_STENCIL_WRITE;
-        _defaultState->_stencilTestEnabled = RS_ALL_ONES;
+		_defaultState->_stencilWrite = RS_ALL_ONES;
     }
 	if (!(stateOverrideBits & RS_STENCIL_FUNC) && (_defaultState->_bits & RS_STENCIL_FUNC))
     {

+ 32 - 0
gameplay/src/lua/lua_Global.cpp

@@ -777,6 +777,34 @@ void luaRegister_lua_Global()
         gameplay::ScriptUtil::registerConstantString("DEPTH_ALWAYS", "DEPTH_ALWAYS", scopePath);
     }
 
+    // Register enumeration RenderState::StencilFunction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NEVER", "STENCIL_NEVER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_ALWAYS", "STENCIL_ALWAYS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LESS", "STENCIL_LESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LEQUAL", "STENCIL_LEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_EQUAL", "STENCIL_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GREATER", "STENCIL_GREATER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GEQUAL", "STENCIL_GEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NOTEQUAL", "STENCIL_NOTEQUAL", scopePath);
+    }
+
+    // Register enumeration RenderState::StencilOperation.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_KEEP", "STENCIL_OP_KEEP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_ZERO", "STENCIL_OP_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_REPLACE", "STENCIL_OP_REPLACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR", "STENCIL_OP_INCR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR", "STENCIL_OP_DECR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INVERT", "STENCIL_OP_INVERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR_WRAP", "STENCIL_OP_INCR_WRAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR_WRAP", "STENCIL_OP_DECR_WRAP", scopePath);
+    }
+
     // Register enumeration Scene::DebugFlags.
     {
         std::vector<std::string> scopePath;
@@ -941,6 +969,10 @@ const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
         return lua_stringFromEnum_RenderStateCullFaceSide((RenderState::CullFaceSide)value);
     if (enumname == "RenderState::DepthFunction")
         return lua_stringFromEnum_RenderStateDepthFunction((RenderState::DepthFunction)value);
+    if (enumname == "RenderState::StencilFunction")
+        return lua_stringFromEnum_RenderStateStencilFunction((RenderState::StencilFunction)value);
+    if (enumname == "RenderState::StencilOperation")
+        return lua_stringFromEnum_RenderStateStencilOperation((RenderState::StencilOperation)value);
     if (enumname == "Scene::DebugFlags")
         return lua_stringFromEnum_SceneDebugFlags((Scene::DebugFlags)value);
     if (enumname == "Terrain::Flags")

+ 2 - 0
gameplay/src/lua/lua_Global.h

@@ -38,6 +38,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 #include "lua_SceneDebugFlags.h"
 #include "lua_TerrainFlags.h"
 #include "lua_TextBoxInputMode.h"

+ 2 - 0
gameplay/src/lua/lua_Material.cpp

@@ -17,6 +17,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 
 namespace gameplay
 {

+ 2 - 0
gameplay/src/lua/lua_Pass.cpp

@@ -14,6 +14,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 
 namespace gameplay
 {

+ 2 - 0
gameplay/src/lua/lua_RenderState.cpp

@@ -13,6 +13,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 
 namespace gameplay
 {

+ 166 - 0
gameplay/src/lua/lua_RenderStateStateBlock.cpp

@@ -13,6 +13,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 
 namespace gameplay
 {
@@ -34,6 +36,10 @@ void luaRegister_RenderStateStateBlock()
         {"setDepthTest", lua_RenderStateStateBlock_setDepthTest},
         {"setDepthWrite", lua_RenderStateStateBlock_setDepthWrite},
         {"setState", lua_RenderStateStateBlock_setState},
+        {"setStencilFunction", lua_RenderStateStateBlock_setStencilFunction},
+        {"setStencilOperation", lua_RenderStateStateBlock_setStencilOperation},
+        {"setStencilTest", lua_RenderStateStateBlock_setStencilTest},
+        {"setStencilWrite", lua_RenderStateStateBlock_setStencilWrite},
         {NULL, NULL}
     };
     const luaL_Reg lua_statics[] = 
@@ -551,6 +557,166 @@ int lua_RenderStateStateBlock_setState(lua_State* state)
     return 0;
 }
 
+int lua_RenderStateStateBlock_setStencilFunction(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                RenderState::StencilFunction param1 = (RenderState::StencilFunction)lua_enumFromString_RenderStateStencilFunction(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
+
+                RenderState::StateBlock* instance = getInstance(state);
+                instance->setStencilFunction(param1, param2, param3);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RenderStateStateBlock_setStencilFunction - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_RenderStateStateBlock_setStencilOperation(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
+                (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                RenderState::StencilOperation param1 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                RenderState::StencilOperation param2 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 3));
+
+                // Get parameter 3 off the stack.
+                RenderState::StencilOperation param3 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 4));
+
+                RenderState::StateBlock* instance = getInstance(state);
+                instance->setStencilOperation(param1, param2, param3);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RenderStateStateBlock_setStencilOperation - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_RenderStateStateBlock_setStencilTest(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TBOOLEAN)
+            {
+                // Get parameter 1 off the stack.
+                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                RenderState::StateBlock* instance = getInstance(state);
+                instance->setStencilTest(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RenderStateStateBlock_setStencilTest - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_RenderStateStateBlock_setStencilWrite(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
+
+                RenderState::StateBlock* instance = getInstance(state);
+                instance->setStencilWrite(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RenderStateStateBlock_setStencilWrite - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_RenderStateStateBlock_static_create(lua_State* state)
 {
     // Get the number of parameters.

+ 4 - 0
gameplay/src/lua/lua_RenderStateStateBlock.h

@@ -19,6 +19,10 @@ int lua_RenderStateStateBlock_setDepthFunction(lua_State* state);
 int lua_RenderStateStateBlock_setDepthTest(lua_State* state);
 int lua_RenderStateStateBlock_setDepthWrite(lua_State* state);
 int lua_RenderStateStateBlock_setState(lua_State* state);
+int lua_RenderStateStateBlock_setStencilFunction(lua_State* state);
+int lua_RenderStateStateBlock_setStencilOperation(lua_State* state);
+int lua_RenderStateStateBlock_setStencilTest(lua_State* state);
+int lua_RenderStateStateBlock_setStencilWrite(lua_State* state);
 int lua_RenderStateStateBlock_static_create(lua_State* state);
 
 void luaRegister_RenderStateStateBlock();

+ 61 - 0
gameplay/src/lua/lua_RenderStateStencilFunction.cpp

@@ -0,0 +1,61 @@
+#include "Base.h"
+#include "lua_RenderStateStencilFunction.h"
+
+namespace gameplay
+{
+
+static const char* enumStringEmpty = "";
+
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_NEVER = "STENCIL_NEVER";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_ALWAYS = "STENCIL_ALWAYS";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_LESS = "STENCIL_LESS";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_LEQUAL = "STENCIL_LEQUAL";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_EQUAL = "STENCIL_EQUAL";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_GREATER = "STENCIL_GREATER";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_GEQUAL = "STENCIL_GEQUAL";
+static const char* luaEnumString_RenderStateStencilFunction_STENCIL_NOTEQUAL = "STENCIL_NOTEQUAL";
+
+RenderState::StencilFunction lua_enumFromString_RenderStateStencilFunction(const char* s)
+{
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_NEVER) == 0)
+        return RenderState::STENCIL_NEVER;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_ALWAYS) == 0)
+        return RenderState::STENCIL_ALWAYS;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_LESS) == 0)
+        return RenderState::STENCIL_LESS;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_LEQUAL) == 0)
+        return RenderState::STENCIL_LEQUAL;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_EQUAL) == 0)
+        return RenderState::STENCIL_EQUAL;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_GREATER) == 0)
+        return RenderState::STENCIL_GREATER;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_GEQUAL) == 0)
+        return RenderState::STENCIL_GEQUAL;
+    if (strcmp(s, luaEnumString_RenderStateStencilFunction_STENCIL_NOTEQUAL) == 0)
+        return RenderState::STENCIL_NOTEQUAL;
+    return RenderState::STENCIL_NEVER;
+}
+
+const char* lua_stringFromEnum_RenderStateStencilFunction(RenderState::StencilFunction e)
+{
+    if (e == RenderState::STENCIL_NEVER)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_NEVER;
+    if (e == RenderState::STENCIL_ALWAYS)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_ALWAYS;
+    if (e == RenderState::STENCIL_LESS)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_LESS;
+    if (e == RenderState::STENCIL_LEQUAL)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_LEQUAL;
+    if (e == RenderState::STENCIL_EQUAL)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_EQUAL;
+    if (e == RenderState::STENCIL_GREATER)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_GREATER;
+    if (e == RenderState::STENCIL_GEQUAL)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_GEQUAL;
+    if (e == RenderState::STENCIL_NOTEQUAL)
+        return luaEnumString_RenderStateStencilFunction_STENCIL_NOTEQUAL;
+    return enumStringEmpty;
+}
+
+}
+

+ 15 - 0
gameplay/src/lua/lua_RenderStateStencilFunction.h

@@ -0,0 +1,15 @@
+#ifndef LUA_RENDERSTATESTENCILFUNCTION_H_
+#define LUA_RENDERSTATESTENCILFUNCTION_H_
+
+#include "RenderState.h"
+
+namespace gameplay
+{
+
+// Lua bindings for enum conversion functions for RenderState::StencilFunction.
+RenderState::StencilFunction lua_enumFromString_RenderStateStencilFunction(const char* s);
+const char* lua_stringFromEnum_RenderStateStencilFunction(RenderState::StencilFunction e);
+
+}
+
+#endif

+ 61 - 0
gameplay/src/lua/lua_RenderStateStencilOperation.cpp

@@ -0,0 +1,61 @@
+#include "Base.h"
+#include "lua_RenderStateStencilOperation.h"
+
+namespace gameplay
+{
+
+static const char* enumStringEmpty = "";
+
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_KEEP = "STENCIL_OP_KEEP";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_ZERO = "STENCIL_OP_ZERO";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_REPLACE = "STENCIL_OP_REPLACE";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR = "STENCIL_OP_INCR";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR = "STENCIL_OP_DECR";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_INVERT = "STENCIL_OP_INVERT";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR_WRAP = "STENCIL_OP_INCR_WRAP";
+static const char* luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR_WRAP = "STENCIL_OP_DECR_WRAP";
+
+RenderState::StencilOperation lua_enumFromString_RenderStateStencilOperation(const char* s)
+{
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_KEEP) == 0)
+        return RenderState::STENCIL_OP_KEEP;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_ZERO) == 0)
+        return RenderState::STENCIL_OP_ZERO;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_REPLACE) == 0)
+        return RenderState::STENCIL_OP_REPLACE;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR) == 0)
+        return RenderState::STENCIL_OP_INCR;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR) == 0)
+        return RenderState::STENCIL_OP_DECR;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_INVERT) == 0)
+        return RenderState::STENCIL_OP_INVERT;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR_WRAP) == 0)
+        return RenderState::STENCIL_OP_INCR_WRAP;
+    if (strcmp(s, luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR_WRAP) == 0)
+        return RenderState::STENCIL_OP_DECR_WRAP;
+    return RenderState::STENCIL_OP_KEEP;
+}
+
+const char* lua_stringFromEnum_RenderStateStencilOperation(RenderState::StencilOperation e)
+{
+    if (e == RenderState::STENCIL_OP_KEEP)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_KEEP;
+    if (e == RenderState::STENCIL_OP_ZERO)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_ZERO;
+    if (e == RenderState::STENCIL_OP_REPLACE)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_REPLACE;
+    if (e == RenderState::STENCIL_OP_INCR)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR;
+    if (e == RenderState::STENCIL_OP_DECR)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR;
+    if (e == RenderState::STENCIL_OP_INVERT)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_INVERT;
+    if (e == RenderState::STENCIL_OP_INCR_WRAP)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_INCR_WRAP;
+    if (e == RenderState::STENCIL_OP_DECR_WRAP)
+        return luaEnumString_RenderStateStencilOperation_STENCIL_OP_DECR_WRAP;
+    return enumStringEmpty;
+}
+
+}
+

+ 15 - 0
gameplay/src/lua/lua_RenderStateStencilOperation.h

@@ -0,0 +1,15 @@
+#ifndef LUA_RENDERSTATESTENCILOPERATION_H_
+#define LUA_RENDERSTATESTENCILOPERATION_H_
+
+#include "RenderState.h"
+
+namespace gameplay
+{
+
+// Lua bindings for enum conversion functions for RenderState::StencilOperation.
+RenderState::StencilOperation lua_enumFromString_RenderStateStencilOperation(const char* s);
+const char* lua_stringFromEnum_RenderStateStencilOperation(RenderState::StencilOperation e);
+
+}
+
+#endif

+ 2 - 0
gameplay/src/lua/lua_Technique.cpp

@@ -14,6 +14,8 @@
 #include "lua_RenderStateBlend.h"
 #include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
 
 namespace gameplay
 {