our_dick/include/graphics/scoped_buffer_bind.hpp

57 lines
1.6 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OUR_DICK_GRAPHICS_SCOPED_BUFFER_BIND_HPP
#define OUR_DICK_GRAPHICS_SCOPED_BUFFER_BIND_HPP
#include "gl_buffers.hpp"
namespace gfx{
template<typename T>
class scoped_buffer_bind
{
public:
using accessor_type = T;
using manager_type = typename T::buffer_type;
protected:
const accessor_type* m_accessor_handle;
manager_type* m_manager_handle;
const accessor_type* m_already_bound;
public:
explicit scoped_buffer_bind(const accessor_type& accessor, manager_type& buffer, bool lock = false);
scoped_buffer_bind(const scoped_buffer_bind&) = delete;
scoped_buffer_bind(scoped_buffer_bind&& s);
~scoped_buffer_bind();
scoped_buffer_bind& operator=(const scoped_buffer_bind&) = delete;
scoped_buffer_bind& operator=(scoped_buffer_bind&& s);
bool valid()const;
void release();
GLenum get_bound_id()const;
GLuint get_buffer_id()const;
};
}
#include "scoped_buffer_bind.tpp"
#endif