Skip to content

Commit

Permalink
added some missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Jun 1, 2023
1 parent d3c6a13 commit b49085d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/ngl/ShaderLib.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ template< typename Ts>
bool ShaderLib::getUniform(std::string_view _paramName, Ts &&o_arg) noexcept
{

if constexpr (std::is_same<Ts,float&>::value || std::is_same<Ts,int&>::value)
if constexpr (std::is_same<Ts,float&>::value ||
std::is_same<Ts,int&>::value ||
is_ngl_matrix<Ts>::value )
{
return m_shaderPrograms[m_currentShader]->getRegisteredUniform(_paramName.data(), o_arg);
}
Expand Down Expand Up @@ -45,6 +47,7 @@ bool ShaderLib::getUniform(std::string_view _paramName, Ts &&o_arg) noexcept

return ret;
}

return false;
}

Expand Down
18 changes: 18 additions & 0 deletions include/ngl/TemplateHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ struct is_std_array : std::false_type {};
template<typename T, std::size_t N>
struct is_std_array<std::array<T,N>> : std::true_type {};

// traits for matrix types
template<typename T>
struct is_ngl_matrix : std::false_type {};
template<>
struct is_ngl_matrix<ngl::Mat2> : std::true_type {};
template<>
struct is_ngl_matrix<ngl::Mat3> : std::true_type {};
template<>
struct is_ngl_matrix<ngl::Mat4> : std::true_type {};
template<typename T>
struct is_ngl_vec : std::false_type {};
template<>
struct is_ngl_vec<ngl::Vec2> : std::true_type {};
template<>
struct is_ngl_vec<ngl::Vec3> : std::true_type {};
template<>
struct is_ngl_vec<ngl::Vec4> : std::true_type {};

// get the value type of the array
template <typename T>
using array_value_type = std::decay_t<decltype(std::declval<T&>()[0])>;
Expand Down

0 comments on commit b49085d

Please sign in to comment.