Browse Source

Allow movement of AbstractShaderProgram.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
cabbc5d858
  1. 9
      src/AbstractShaderProgram.cpp
  2. 17
      src/AbstractShaderProgram.h

9
src/AbstractShaderProgram.cpp

@ -88,6 +88,10 @@ Int AbstractShaderProgram::maxSupportedVertexAttributeCount() {
AbstractShaderProgram::AbstractShaderProgram(): _id(glCreateProgram()) {}
AbstractShaderProgram::AbstractShaderProgram(AbstractShaderProgram&& other) noexcept: _id(other._id) {
other._id = 0;
}
AbstractShaderProgram::~AbstractShaderProgram() {
/* Remove current usage from the state */
GLuint& current = Context::current()->state()->shaderProgram->current;
@ -96,6 +100,11 @@ AbstractShaderProgram::~AbstractShaderProgram() {
if(_id) glDeleteProgram(_id);
}
AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& other) noexcept {
std::swap(_id, other._id);
return *this;
}
std::pair<bool, std::string> AbstractShaderProgram::validate() {
glValidateProgram(_id);

17
src/AbstractShaderProgram.h

@ -286,11 +286,6 @@ comes in handy.
class MAGNUM_EXPORT AbstractShaderProgram {
friend class Context;
AbstractShaderProgram(const AbstractShaderProgram&) = delete;
AbstractShaderProgram(AbstractShaderProgram&&) = delete;
AbstractShaderProgram& operator=(const AbstractShaderProgram&) = delete;
AbstractShaderProgram& operator=(AbstractShaderProgram&&) = delete;
public:
template<UnsignedInt, class> class Attribute;
@ -311,6 +306,12 @@ class MAGNUM_EXPORT AbstractShaderProgram {
*/
explicit AbstractShaderProgram();
/** @brief Copying is not allowed */
AbstractShaderProgram(const AbstractShaderProgram&) = delete;
/** @brief Move constructor */
AbstractShaderProgram(AbstractShaderProgram&& other) noexcept;
/**
* @brief Destructor
*
@ -319,6 +320,12 @@ class MAGNUM_EXPORT AbstractShaderProgram {
*/
virtual ~AbstractShaderProgram() = 0;
/** @brief Copying is not allowed */
AbstractShaderProgram& operator=(const AbstractShaderProgram&) = delete;
/** @brief Move assignment */
AbstractShaderProgram& operator=(AbstractShaderProgram&& other) noexcept;
/** @brief OpenGL program ID */
GLuint id() const { return _id; }

Loading…
Cancel
Save