48 lines
913 B
C++
48 lines
913 B
C++
#ifndef INCLUDE_SHADER_DATA_IMPLEMENTATION
|
|
# error Never include this file directly include 'shader_data.hpp'
|
|
#endif
|
|
|
|
namespace zgl
|
|
{
|
|
inline shader_data::shader_data(const GLuint shader_id, const GLenum type)
|
|
: m_handle{ shader_id }, m_type{ type } {}
|
|
|
|
|
|
inline shader_data::shader_data(shader_data&& other) noexcept
|
|
{
|
|
m_handle = other.m_handle;
|
|
m_type = other.m_type;
|
|
other.m_handle.shader_id = 0;
|
|
other.m_type = GL_INVALID_ENUM;
|
|
}
|
|
|
|
inline shader_data& shader_data::operator=(shader_data&& other) noexcept
|
|
{
|
|
if (&other != this)
|
|
{
|
|
this->~shader_data();
|
|
|
|
m_handle = other.m_handle;
|
|
m_type = other.m_type;
|
|
other.m_handle.shader_id = 0;
|
|
other.m_type = GL_INVALID_ENUM;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
inline shader_data::~shader_data()
|
|
{
|
|
if (m_handle.shader_id)
|
|
{
|
|
glDeleteShader(m_handle.shader_id);
|
|
}
|
|
m_type = GL_INVALID_ENUM;
|
|
}
|
|
|
|
inline shader_handle shader_data::handle() const
|
|
{
|
|
return m_handle;
|
|
}
|
|
|
|
}
|