MCPcopy Create free account
hub / github.com/defold/defold / RenderScript_Draw

Function RenderScript_Draw

engine/render/src/render/render_script.cpp:1720–1809  ·  view source on GitHub ↗

draws all objects matching a predicate * Draws all objects that match a specified predicate. An optional constant buffer can be * provided to override the default constants. If no constants buffer is provided, a default * system constants buffer is used containing constants as defined in materials and set through * [ref:go.set] (or [ref:particlefx.set_constant]) on visual compo

Source from the content-addressed store, hash-verified

1718 * ```
1719 */
1720 int RenderScript_Draw(lua_State* L)
1721 {
1722 RenderScriptInstance* i = RenderScriptInstance_Check(L);
1723 HPredicate predicate = 0x0;
1724 if (lua_isuserdata(L, 1))
1725 {
1726 HPredicate* tmp = RenderScriptPredicate_Check(L, 1);
1727 predicate = *tmp;
1728 }
1729 else
1730 {
1731 return luaL_error(L, "No render predicate specified.");
1732 }
1733
1734 dmVMath::Matrix4* frustum_matrix = 0;
1735 dmRender::FrustumPlanes frustum_num_planes = dmRender::FRUSTUM_PLANES_SIDES;
1736 HNamedConstantBuffer constant_buffer = 0;
1737 dmRender::SortOrder sort_order = dmRender::SORT_UNSPECIFIED;
1738
1739 bool has_options_table = lua_istable(L, 2);
1740 if (lua_gettop(L) >=2 && !has_options_table)
1741 {
1742 return luaL_error(L, "Invalid argument #2 type. Should be table or nil");
1743 }
1744 bool has_constant_buffer_value = false;
1745
1746 if (has_options_table)
1747 {
1748 luaL_checktype(L, 2, LUA_TTABLE);
1749 lua_pushvalue(L, 2);
1750 int options_index = lua_gettop(L);
1751
1752 lua_getfield(L, options_index, "frustum");
1753 frustum_matrix = lua_isnil(L, -1) ? 0 : dmScript::CheckMatrix4(L, -1);
1754 lua_pop(L, 1);
1755
1756 lua_getfield(L, options_index, "frustum_planes");
1757 frustum_num_planes = lua_isnil(L, -1) ? frustum_num_planes : (dmRender::FrustumPlanes)luaL_checkinteger(L, -1);
1758 lua_pop(L, 1);
1759
1760 lua_getfield(L, options_index, "constants");
1761 if (!lua_isnil(L, -1))
1762 {
1763 constant_buffer = *RenderScriptConstantBuffer_Check(L, -1);
1764 has_constant_buffer_value = true;
1765 }
1766
1767 lua_getfield(L, options_index, "sort_order");
1768 if (!lua_isnil(L, -1))
1769 {
1770 sort_order = (dmRender::SortOrder) luaL_checkinteger(L, -1);
1771 }
1772 lua_pop(L, 1);
1773 }
1774
1775 // we need to pass ownership to the command queue
1776 FrustumOptions* frustum_options = 0;
1777 if (frustum_matrix)

Callers

nothing calls this directly

Calls 15

lua_isuserdataFunction · 0.85
luaL_errorFunction · 0.85
lua_gettopFunction · 0.85
luaL_checktypeFunction · 0.85
lua_pushvalueFunction · 0.85
lua_getfieldFunction · 0.85
CheckMatrix4Function · 0.85
luaL_checkintegerFunction · 0.85
InsertCommandFunction · 0.85

Tested by

no test coverage detected