GLS  1.0.0
GL Stuff - A library aimed at reducing the boilerplate OpenGL code you always have to write.
object.hpp
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 #include <gls/headercheck.hpp>
8 #include <gls/errorcheck.hpp>
9 #include <utility>
10 
11 namespace gls {
12 
20 template<void (*Generator)(GLsizei, GLuint*), void (*Deleter)(GLsizei, const GLuint*)>
21 class object {
22 public:
27  object() {
28  check_gl_error( Generator( 1, &m_name ) );
29  }
30 
35  ~object() {
36  check_gl_error( Deleter( 1, &m_name ) );
37  }
38 
45  object( object&& other ) :
46  m_name( 0u )
47  {
48  std::swap( m_name, other.m_name );
49  }
50 
58  object& operator=( object&& other ) {
59  std::swap( m_name, other.m_name );
60  return *this;
61  }
62 
67  object( const object& ) = delete;
68  operator=( const object& ) = delete;
73 
80  GLuint name() const {
81  return m_name;
82  }
83 
84 private:
85  GLuint m_name;
86 };
87 
88 }
89 
GLuint name() const
Retrieve the OpenGL name of this buffer.
Definition: object.hpp:80
object()
Default constructor.
Definition: object.hpp:27
~object()
Default destructor.
Definition: object.hpp:35
object & operator=(object &&other)
Move assignment.
Definition: object.hpp:58
object(object &&other)
Move constructor.
Definition: object.hpp:45
A RAII wrapper around any OpenGL object.
Definition: object.hpp:21
Definition: buffer.hpp:12