From 3f78fbe65389624a9125ee593c284e8f70bf535e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 25 Jan 2024 22:46:14 +0000 Subject: Replace static_asserts with concepts --- lib/gl_traits.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/gl_traits.h b/lib/gl_traits.h index dcbe04e..f641131 100644 --- a/lib/gl_traits.h +++ b/lib/gl_traits.h @@ -99,56 +99,51 @@ struct gl_traits> : public gl_traits { }; template +concept has_glUniform1 = requires { gl_traits::glUniformFunc; }; +template +concept has_glUniformNv = requires { gl_traits::glUniformvFunc; }; +template +concept has_glUniformMatrixNv = requires { gl_traits::glUniformmFunc; }; + +template void glUniform(GLint location, T v) { - static_assert( - requires { gl_traits::glUniformFunc; }, "Has glUnform1T"); (*gl_traits::glUniformFunc)(location, v); } -template +template void glUniform(GLint location, const glm::vec & v) { - static_assert( - requires { gl_traits::glUniformFunc; }, "Has glUnformNTv"); (*gl_traits::glUniformvFunc[L - 1])(location, 1, glm::value_ptr(v)); } -template +template void glUniform(GLint location, std::span> v) { - static_assert( - requires { gl_traits::glUniformvFunc; }, "Has glUnformNTv"); (*gl_traits::glUniformvFunc[L - 1])(location, static_cast(v.size()), glm::value_ptr(v.front())); } -template +template void glUniform(GLint location, std::span v) { - static_assert( - requires { gl_traits::glUniformvFunc; }, "Has glUnformNTv"); (*gl_traits::glUniformvFunc.front())(location, static_cast(v.size()), v.data()); } -template +template void glUniform(GLint location, const glm::mat & v) { - static_assert( - requires { gl_traits::glUniformmFunc; }, "Has glUnformMatrixNTv"); (*gl_traits::glUniformmFunc[L - 2])(location, 1, GL_FALSE, glm::value_ptr(v)); } -template +template void glUniform(GLint location, std::span> v) { - static_assert( - requires { gl_traits::glUniformmFunc; }, "Has glUnformMatrixNTv"); (*gl_traits::glUniformmFunc[L - 2])( location, static_cast(v.size()), GL_FALSE, glm::value_ptr(v.front())); } -- cgit v1.2.3