Support vector, point & interval uniforms of unknown floating-point/integral types
This commit is contained in:
parent
3472bf056b
commit
daeba8674a
1 changed files with 81 additions and 0 deletions
|
|
@ -53,6 +53,9 @@ namespace psemek::gfx
|
|||
void operator = (geom::vector<float, 3> const & v);
|
||||
void operator = (geom::vector<float, 4> const & v);
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
void operator = (geom::vector<T, D> const & v);
|
||||
|
||||
void operator = (geom::point<int, 1> const & v);
|
||||
void operator = (geom::point<int, 2> const & v);
|
||||
void operator = (geom::point<int, 3> const & v);
|
||||
|
|
@ -68,6 +71,9 @@ namespace psemek::gfx
|
|||
void operator = (geom::point<float, 3> const & v);
|
||||
void operator = (geom::point<float, 4> const & v);
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
void operator = (geom::point<T, D> const & v);
|
||||
|
||||
void operator = (geom::matrix<float, 2, 2> const & m);
|
||||
void operator = (geom::matrix<float, 2, 3> const & m);
|
||||
void operator = (geom::matrix<float, 2, 4> const & m);
|
||||
|
|
@ -82,6 +88,9 @@ namespace psemek::gfx
|
|||
void operator = (geom::interval<unsigned int> const & i);
|
||||
void operator = (geom::interval<float> const & i);
|
||||
|
||||
template <typename T>
|
||||
void operator = (geom::interval<T> const & i);
|
||||
|
||||
private:
|
||||
GLint location_;
|
||||
};
|
||||
|
|
@ -93,4 +102,76 @@ namespace psemek::gfx
|
|||
mutable std::unordered_map<std::string, GLint> uniforms_;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
void program::uniform_proxy::operator = (geom::vector<T, D> const & v)
|
||||
{
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<float>(v);
|
||||
}
|
||||
else if (std::is_integral_v<T>)
|
||||
{
|
||||
if constexpr (std::is_unsigned_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<unsigned int>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) = geom::cast<int>(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert("Unknown uniform data type");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
void program::uniform_proxy::operator = (geom::point<T, D> const & p)
|
||||
{
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<float>(p);
|
||||
}
|
||||
else if (std::is_integral_v<T>)
|
||||
{
|
||||
if constexpr (std::is_unsigned_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<unsigned int>(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) = geom::cast<int>(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert("Unknown uniform data type");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void program::uniform_proxy::operator = (geom::interval<T> const & i)
|
||||
{
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<float>(i);
|
||||
}
|
||||
else if (std::is_integral_v<T>)
|
||||
{
|
||||
if constexpr (std::is_unsigned_v<T>)
|
||||
{
|
||||
(*this) = geom::cast<unsigned int>(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) = geom::cast<int>(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert("Unknown uniform data type");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue