<commit_before>
#include "uniform.h"

#include <scm/gl_core/render_device/device.h>
#include <scm/gl_core/render_device/context.h>
#include <scm/gl_core/render_device/opengl/gl3_core.h>
#include <scm/gl_core/render_device/opengl/util/assert.h>
#include <scm/gl_core/render_device/opengl/util/binding_guards.h>
#include <scm/gl_core/render_device/opengl/util/constants_helper.h>
#include <scm/gl_core/render_device/opengl/util/data_type_helper.h>
#include <scm/gl_core/render_device/opengl/util/error_helper.h>

namespace scm {
namespace gl {

template<typename T, data_type D>
uniform<T, D>::uniform(const std::string& n, const int l, const unsigned e, const data_type t)
  : uniform_base(n, l, e, t)
{
}

template<typename T, data_type D>
uniform<T, D>::~uniform()
{
}

template<typename T, data_type D>
typename uniform<T, D>::value_param_type
uniform<T, D>::value() const
{
    return (_value);
}

template<typename T, data_type D>
void
uniform<T, D>::value(value_param_type v)
{
    if (v != _value) {
        _value = v;
        _update_required = true;
    }
}


} // namespace gl
} // namespace scm

#include <scm/core/utilities/platform_warning_disable.h>

// instantiate the uniform templates //////////////////////////////////////////////////////////////
#define SCM_UNIFORM_TYPE_INSTANTIATE(type_raw, type_id, uniform_type_name)               \
    template class __scm_export(gl_core)                 scm::gl::uniform<type_raw, type_id>;

//namespace scm {
//namespace gl {

SCM_UNIFORM_TYPE_INSTANTIATE(float,             scm::gl::TYPE_FLOAT,  uniform_1f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2f,  scm::gl::TYPE_VEC2F,  uniform_vec2f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3f,  scm::gl::TYPE_VEC3F,  uniform_vec3f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4f,  scm::gl::TYPE_VEC4F,  uniform_vec4f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat2f,  scm::gl::TYPE_MAT2F,  uniform_mat2f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat3f,  scm::gl::TYPE_MAT3F,  uniform_mat3f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat4f,  scm::gl::TYPE_MAT4F,  uniform_mat4f)

SCM_UNIFORM_TYPE_INSTANTIATE(int,               scm::gl::TYPE_INT,    uniform_1i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2i,  scm::gl::TYPE_VEC2I,  uniform_vec2i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3i,  scm::gl::TYPE_VEC3I,  uniform_vec3i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4i,  scm::gl::TYPE_VEC4I,  uniform_vec4i)

SCM_UNIFORM_TYPE_INSTANTIATE(unsigned,          scm::gl::TYPE_UINT,   uniform_1ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2ui, scm::gl::TYPE_VEC2UI, uniform_vec2ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3ui, scm::gl::TYPE_VEC3UI, uniform_vec3ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4ui, scm::gl::TYPE_VEC4UI, uniform_vec4ui)

#if SCM_GL_CORE_OPENGL_40
SCM_UNIFORM_TYPE_INSTANTIATE(double,            scm::gl::TYPE_DOUBLE, uniform_1d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2d,  scm::gl::TYPE_VEC2D,  uniform_vec2d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3d,  scm::gl::TYPE_VEC3D,  uniform_vec3d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4d,  scm::gl::TYPE_VEC4D,  uniform_vec4d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat2d,  scm::gl::TYPE_MAT2D,  uniform_mat2d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat3d,  scm::gl::TYPE_MAT3D,  uniform_mat3d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat4d,  scm::gl::TYPE_MAT4D,  uniform_mat4d)
#endif // SCM_GL_CORE_OPENGL_40

//} // namespace gl
//} // namespace scm

#undef SCM_UNIFORM_TYPE_INSTANTIATE

namespace scm {
namespace gl {

uniform_base::uniform_base(const std::string& n, const int l, const unsigned e, const data_type t)
  : _name(n)
  , _location(l)
  , _elements(e)
  , _update_required(false)
  , _type(t)
{
}

uniform_base::~uniform_base()
{
}

const std::string&
uniform_base::name() const
{
    return (_name);
}

const int
uniform_base::location() const
{
    return (_location);
}

const unsigned
uniform_base::elements() const
{
    return (_elements);
}

const data_type
uniform_base::type() const<commit_msg>forced initial uniform update, maybe introduce default value for specific uniform specializations<commit_after>
#include "uniform.h"

#include <scm/gl_core/render_device/device.h>
#include <scm/gl_core/render_device/context.h>
#include <scm/gl_core/render_device/opengl/gl3_core.h>
#include <scm/gl_core/render_device/opengl/util/assert.h>
#include <scm/gl_core/render_device/opengl/util/binding_guards.h>
#include <scm/gl_core/render_device/opengl/util/constants_helper.h>
#include <scm/gl_core/render_device/opengl/util/data_type_helper.h>
#include <scm/gl_core/render_device/opengl/util/error_helper.h>

namespace scm {
namespace gl {

template<typename T, data_type D>
uniform<T, D>::uniform(const std::string& n, const int l, const unsigned e, const data_type t)
  : uniform_base(n, l, e, t)
{
}

template<typename T, data_type D>
uniform<T, D>::~uniform()
{
}

template<typename T, data_type D>
typename uniform<T, D>::value_param_type
uniform<T, D>::value() const
{
    return (_value);
}

template<typename T, data_type D>
void
uniform<T, D>::value(value_param_type v)
{
    if (v != _value) {
        _value = v;
        _update_required = true;
    }
}

} // namespace gl
} // namespace scm

#include <scm/core/utilities/platform_warning_disable.h>

// instantiate the uniform templates //////////////////////////////////////////////////////////////
#define SCM_UNIFORM_TYPE_INSTANTIATE(type_raw, type_id, uniform_type_name)               \
    template class __scm_export(gl_core)                 scm::gl::uniform<type_raw, type_id>;

//namespace scm {
//namespace gl {

SCM_UNIFORM_TYPE_INSTANTIATE(float,             scm::gl::TYPE_FLOAT,  uniform_1f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2f,  scm::gl::TYPE_VEC2F,  uniform_vec2f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3f,  scm::gl::TYPE_VEC3F,  uniform_vec3f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4f,  scm::gl::TYPE_VEC4F,  uniform_vec4f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat2f,  scm::gl::TYPE_MAT2F,  uniform_mat2f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat3f,  scm::gl::TYPE_MAT3F,  uniform_mat3f)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat4f,  scm::gl::TYPE_MAT4F,  uniform_mat4f)

SCM_UNIFORM_TYPE_INSTANTIATE(int,               scm::gl::TYPE_INT,    uniform_1i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2i,  scm::gl::TYPE_VEC2I,  uniform_vec2i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3i,  scm::gl::TYPE_VEC3I,  uniform_vec3i)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4i,  scm::gl::TYPE_VEC4I,  uniform_vec4i)

SCM_UNIFORM_TYPE_INSTANTIATE(unsigned,          scm::gl::TYPE_UINT,   uniform_1ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2ui, scm::gl::TYPE_VEC2UI, uniform_vec2ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3ui, scm::gl::TYPE_VEC3UI, uniform_vec3ui)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4ui, scm::gl::TYPE_VEC4UI, uniform_vec4ui)

#if SCM_GL_CORE_OPENGL_40
SCM_UNIFORM_TYPE_INSTANTIATE(double,            scm::gl::TYPE_DOUBLE, uniform_1d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec2d,  scm::gl::TYPE_VEC2D,  uniform_vec2d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec3d,  scm::gl::TYPE_VEC3D,  uniform_vec3d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::vec4d,  scm::gl::TYPE_VEC4D,  uniform_vec4d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat2d,  scm::gl::TYPE_MAT2D,  uniform_mat2d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat3d,  scm::gl::TYPE_MAT3D,  uniform_mat3d)
SCM_UNIFORM_TYPE_INSTANTIATE(scm::math::mat4d,  scm::gl::TYPE_MAT4D,  uniform_mat4d)
#endif // SCM_GL_CORE_OPENGL_40

//} // namespace gl
//} // namespace scm

#undef SCM_UNIFORM_TYPE_INSTANTIATE

namespace scm {
namespace gl {

uniform_base::uniform_base(const std::string& n, const int l, const unsigned e, const data_type t)
  : _name(n)
  , _location(l)
  , _elements(e)
  , _update_required(true)
  , _type(t)
{
}

uniform_base::~uniform_base()
{
}

const std::string&
uniform_base::name() const
{
    return (_name);
}

const int
uniform_base::location() const
{
    return (_location);
}

const unsigned
uniform_base::elements() const
{
    return (_elements);
}

const data_type
uniform_base::type() const
{'fraction_non_alphanumeric': 0.14470443349753695, 'fraction_numerical': 0.015517241379310345, 'mean_word_length': 5.830109335576115, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736103', 'n_tokens_mistral': 3417, 'n_tokens_neox': 3413, 'n_words': 450}