diff options
author | chai <chaifix@163.com> | 2021-10-29 15:02:46 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-29 15:02:46 +0800 |
commit | 796b4b05ec62eb5d58a634854998f485072e8a2b (patch) | |
tree | 30f188382f14b3b9c69fe5846262a39a8b4664cc /Runtime/Scripting/Rendering/Shader.bind.cpp | |
parent | 91c32cb173201ac8803a1e4452e8342969b8e484 (diff) |
*passing texture to glsl
Diffstat (limited to 'Runtime/Scripting/Rendering/Shader.bind.cpp')
-rw-r--r-- | Runtime/Scripting/Rendering/Shader.bind.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Runtime/Scripting/Rendering/Shader.bind.cpp b/Runtime/Scripting/Rendering/Shader.bind.cpp index 89f1ebb..83f8477 100644 --- a/Runtime/Scripting/Rendering/Shader.bind.cpp +++ b/Runtime/Scripting/Rendering/Shader.bind.cpp @@ -15,12 +15,13 @@ LUA_BIND_REGISTRY(Shader) { "Use", _Use }, { "Unuse", _UnUse }, //{ "SetColor", _SetColor }, + { "SetTexture", _SetTexture }, { "SetVector2", _SetVector2 }, { "SetVector3", _SetVector3 }, { "SetVector4", _SetVector4 }, //{ "SetMatrix3", _SetMatrix3 }, { "SetMatrix44", _SetMatrix4 } - ); + ); } LUA_BIND_POSTPROCESS(Shader) @@ -160,4 +161,18 @@ LUA_BIND_IMPL_METHOD(Shader, _SetMatrix4) g_GfxDevice.SetUniformMat4(name, m4); return 1; -}
\ No newline at end of file +} + +// shader:SetTexture(name,texture) +LUA_BIND_IMPL_METHOD(Shader, _SetTexture) +{ + LUA_BIND_PREPARE(L, Shader); + LUA_BIND_CHECK(L, "USU"); + + cc8* name = state.GetValue(2, ""); + Texture* tex = state.GetUserdata<Texture>(); + + g_GfxDevice.SetUniformTexture(name, tex); + + return 1; +} |