From d4ae68b6ba5211c7bc11a52951c466c5050ae377 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 21 Jan 2024 01:34:10 +0000 Subject: String view/constexpr Shader instances Gonna need more constexpr stuff and strstr/strlen aren't that --- lib/embed-glsl.cpp.m4 | 9 +++------ lib/strlen.h | 14 -------------- 2 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 lib/strlen.h (limited to 'lib') diff --git a/lib/embed-glsl.cpp.m4 b/lib/embed-glsl.cpp.m4 index 60fb56b..9fe0b41 100644 --- a/lib/embed-glsl.cpp.m4 +++ b/lib/embed-glsl.cpp.m4 @@ -1,12 +1,9 @@ changecom() dnl // NAME #include "gfx/gl/shader.h" -#include "lib/strlen.h" #include "substr(TYPE,1)-NAME.h" #include - constexpr const GLchar * src {R"GLSL-EMBED(dnl -include(SOURCE))GLSL-EMBED"}; -constexpr auto len {constexpr_strlen(src)}; - -const Shader NAME`_'substr(TYPE,1) { src, len, GLTYPE }; +constexpr Shader NAME`_'substr(TYPE,1) { + R"GLSL-EMBED(dnl + include(SOURCE))GLSL-EMBED", GLTYPE }; diff --git a/lib/strlen.h b/lib/strlen.h deleted file mode 100644 index 2090d25..0000000 --- a/lib/strlen.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -constexpr auto -constexpr_strlen(const GLchar * const s) -{ - std::size_t ch {}; - while (s[ch]) { - ch++; - } - return ch; -} -- cgit v1.2.3 From 903e959080837d1f15e8689f095624cccfc3ceda Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 22 Jan 2024 01:45:01 +0000 Subject: Add missing support for glUniform simple span of numbers --- lib/gl_traits.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/gl_traits.h b/lib/gl_traits.h index 2d3d85d..dcbe04e 100644 --- a/lib/gl_traits.h +++ b/lib/gl_traits.h @@ -125,6 +125,15 @@ glUniform(GLint location, std::span> v) (*gl_traits::glUniformvFunc[L - 1])(location, static_cast(v.size()), glm::value_ptr(v.front())); } +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 void glUniform(GLint location, const glm::mat & v) -- cgit v1.2.3