12#ifndef GAMP_GLSLUNIFORMDATA_HPP_
13#define GAMP_GLSLUNIFORMDATA_HPP_
36 using namespace gamp::render::gl;
37 using namespace jau::math::util;
52 virtual const
void*
data() const noexcept = 0;
60 constexpr GLint
location() const noexcept {
return m_location; }
79 m_location = ::glGetUniformLocation(program, m_name.c_str());
84 constexpr GLsizei
count() const noexcept {
return m_count; }
86 constexpr GLsizei
components() const noexcept {
return m_rows*m_columns; }
88 constexpr GLsizei
rows() const noexcept {
return m_rows; }
90 constexpr GLsizei
columns() const noexcept {
return m_columns; }
92 constexpr bool isMatrix() const noexcept {
return m_rows > 1 && m_columns > 1; }
94 constexpr bool isVector() const noexcept {
return m_rows == 1 && m_columns > 1; }
96 constexpr bool isScalar() const noexcept {
return m_rows == 1 && m_columns == 1; }
101 .append(
", name ").append(m_name)
102 .append(
", location ").append(std::to_string(m_location))
103 .append(
", size ").append(std::to_string(m_rows)).append(
"x").append(std::to_string(m_columns))
104 .append(
", count ").append(std::to_string(m_count))
109 const GLfloat* d =
reinterpret_cast<const GLfloat*
>(
data());
110 for( GLsizei i = 0; i < m_count; ++i ) {
111 if( i > 0 ) { sb.append(
"\n"); }
113 d+
static_cast<ptrdiff_t
>(i*m_rows*m_columns), m_rows, m_columns,
false);
118 const GLfloat* d =
reinterpret_cast<const GLfloat*
>(
data());
123 const GLfloat d = *
reinterpret_cast<const GLfloat*
>(
data());
124 sb.append(std::to_string(d));
126 const GLint d = *
reinterpret_cast<const GLint*
>(
data());
127 sb.append(std::to_string(d));
151 GLsizei m_rows, m_columns, m_count;
163 -1, 4, 4,
data.matrixCount()),
167 return std::make_shared<GLUniformSyncMatrices4f>(
name,
data);
169 const void*
data() const noexcept
override {
return m_data.syncedData(); }
171 constexpr const GLfloat*
floats()
const {
return m_data.floats(); }
186 return std::make_shared<GLUniformVec4f>(
name, v);
188 const void*
data() const noexcept
override {
return m_data.cbegin(); }
206 return std::make_shared<GLUniformVec3f>(
name, v);
208 const void*
data() const noexcept
override {
return m_data.cbegin(); }
static const jau::type_info & f32()
jau::float_32_t or just float
static const jau::type_info & i32()
int32_t
SyncBuffer interface with multiple underlying Matrix4.
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
std::string & row_to_string(std::string &sb, const std::string &f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder, const jau::nsize_t row) noexcept
Appends a row of floating points to the given string sb
std::string & mat_to_string(std::string &sb, const std::string &rowPrefix, const std::string &f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder) noexcept
Appends a matrix of floating points to the given string sb
std::shared_ptr< GLUniformSyncMatrices4f > GLUniformSyncMatrices4fRef
std::shared_ptr< GLUniformData > GLUniformDataRef
std::shared_ptr< GLUniformVec4f > GLUniformVec4fRef
std::shared_ptr< GLUniformVec3f > GLUniformVec3fRef
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.