From a9cf61759dc243c4051467d7223138e04b56c7dc Mon Sep 17 00:00:00 2001 From: Patrick Meehan Date: Sat, 1 Dec 2018 23:18:08 -0800 Subject: [PATCH] exposed MOAIDraw::Bind () to lua; updated audio-meter sample to not crash on render --- samples/audio-meter/main.lua | 8 +++++--- src/moai-sim/MOAIDraw.cpp | 10 ++++++++++ src/moai-sim/MOAIDraw.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/samples/audio-meter/main.lua b/samples/audio-meter/main.lua index 5b2dd15691..7e955052d0 100644 --- a/samples/audio-meter/main.lua +++ b/samples/audio-meter/main.lua @@ -15,7 +15,7 @@ viewport = MOAIViewport.new () viewport:setSize ( 1024, 512 ) viewport:setScale ( 1024, 512 ) -layer = MOAIPartitionViewLayer.new () +layer = MOAITableViewLayer.new () layer:setViewport ( viewport ) layer:setClearColor ( 1, 1, 1, 1 ) layer:pushRenderPass () @@ -86,6 +86,8 @@ elapsedFrames = 0 onDraw = function () + MOAIDraw.bind () + meter:seek ( 0 ) local span = 1024 / bands @@ -95,9 +97,9 @@ onDraw = function () local x = (( i - 1 ) * span ) - ( 1024 / 2 ) local y = ( meter:readFloat () * 64 ) - 256 - MOAIGfxMgr.setPenColor ( 1, 0, 0, 1 ) + MOAIDraw.setPenColor ( 1, 0, 0, 1 ) MOAIDraw.fillRect ( x, y, x + span, -256 ) end end -layer:setOverlayTable ({ onDraw }) +layer:setRenderTable ({ onDraw }) diff --git a/src/moai-sim/MOAIDraw.cpp b/src/moai-sim/MOAIDraw.cpp index cdf5001427..c44e49bf1d 100644 --- a/src/moai-sim/MOAIDraw.cpp +++ b/src/moai-sim/MOAIDraw.cpp @@ -293,6 +293,15 @@ void MOAIDraw::EndDrawString () { // lua //================================================================// +//----------------------------------------------------------------// +// TODO: doxygen +int MOAIDraw::_bind ( lua_State* L ) { + MOAI_LUA_SETUP_SINGLE ( MOAIDraw, "" ) + + self->Bind (); + return 0; +} + //----------------------------------------------------------------// // TODO: doxygen int MOAIDraw::_bindFrameBuffer ( lua_State* L ) { @@ -1546,6 +1555,7 @@ void MOAIDraw::RegisterLuaClass ( MOAILuaState& state ) { state.SetField ( -1, "WORLD_MATRIX", ( u32 )MOAIGfxState::MODEL_TO_WORLD_MTX ); luaL_Reg regTable [] = { + { "bind", _bind }, { "bindFrameBuffer", _bindFrameBuffer }, { "bindIndexBuffer", _bindIndexBuffer }, { "bindShader", _bindShader }, diff --git a/src/moai-sim/MOAIDraw.h b/src/moai-sim/MOAIDraw.h index caf783fd3d..9f1bb45bc0 100644 --- a/src/moai-sim/MOAIDraw.h +++ b/src/moai-sim/MOAIDraw.h @@ -27,6 +27,7 @@ class MOAIDraw : private: //----------------------------------------------------------------// + static int _bind ( lua_State* L ); static int _bindFrameBuffer ( lua_State* L ); static int _bindIndexBuffer ( lua_State* L ); static int _bindShader ( lua_State* L );