From 796b4b05ec62eb5d58a634854998f485072e8a2b Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Oct 2021 15:02:46 +0800 Subject: *passing texture to glsl --- Runtime/Scripting/Rendering/Shader.bind.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Runtime/Scripting/Rendering/Shader.bind.cpp') 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(); + + g_GfxDevice.SetUniformTexture(name, tex); + + return 1; +} -- cgit v1.1-26-g67d0