301    , m_filter { filter }
 
  302    , m_resolution { res }
 
  303    , m_antialias { (samples == 
tex_samples::MSAA_X1) ? texture_antialias { GL_TEXTURE_2D, samples } : texture_antialias { GL_TEXTURE_2D_MULTISAMPLE, samples } }
 
  305    glGenTextures(1, &m_id);
 
  306    glBindTexture(m_antialias.type, m_id);
 
  308    if (m_antialias.type == GL_TEXTURE_2D) {
 
  309        glTexParameteri(m_antialias.type, GL_TEXTURE_MIN_FILTER, generate_mipmap ? 
to_mipmap(filter.min_filter) : filter.min_filter);
 
  310        glTexParameteri(m_antialias.type, GL_TEXTURE_MAG_FILTER, filter.mag_filter);
 
  311        glTexParameteri(m_antialias.type, GL_TEXTURE_WRAP_S, filter.clamping);
 
  312        glTexParameteri(m_antialias.type, GL_TEXTURE_WRAP_T, filter.clamping);
 
  314        glTexImage2D(m_antialias.type, 0, color.internal_format, m_resolution.width, m_resolution.height, 0, color.format, color.datatype, data.data());
 
  315    } 
else if (m_antialias.type == GL_TEXTURE_2D_MULTISAMPLE) {
 
  316        glTexImage2DMultisample(m_antialias.type, m_antialias.samples, color.internal_format,
 
  317            m_resolution.width, m_resolution.height, GL_TRUE);
 
  320    if (generate_mipmap) {
 
  321        glGenerateMipmap(m_antialias.type);
 
  324    glBindTexture(m_antialias.type, 0);
 
 
constexpr auto id() const -> std::uint32_t
Get the id of the texture object.
 
constexpr auto filter() const -> texture_filter
Get the texture filter struct.
 
void set_unit(std::uint32_t unit_offset)
Activate the texture on a unit.
 
constexpr auto antialias() const -> texture_antialias
Get the texture antialias struct.
 
auto operator=(const texture_2d &) -> texture_2d &=delete
 
texture_2d(texture_2d &&other) noexcept
Construct a new texture 2d object.
 
void unbind() const
Unbind the texture object.
 
texture_2d(const texture_2d &)=delete
 
auto constexpr get_unit() const -> uint32_t
Get the last texture unit this texture was bound to.
 
texture_2d()=default
Construct a new texture 2d object.
 
auto operator=(texture_2d &&other) noexcept -> texture_2d &
Move assignment operator.
 
texture_antialias m_antialias
 
constexpr auto get_resolution() const -> staplegl::resolution
Get the resolution of the texture object.
 
constexpr auto color() const -> texture_color
Get the texture color struct.
 
void set_data(std::span< const float > data, resolution res, texture_color color, bool generate_mipmap=false)
Set the data object.
 
OpenGL texture details relating to the number of samples to use for the texture.
 
OpenGL texture details relating to the color format and data type.
 
std::int32_t internal_format
 
OpenGL texture details relating to filtering and clamping of the image.