GLS  1.0.0
GL Stuff - A library aimed at reducing the boilerplate OpenGL code you always have to write.
buffertexture.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 <gls/objects/buffer.hpp>
10 #include <gls/objects/texture.hpp>
11 
12 namespace gls {
13 
20 template<GLenum InternalFormat>
21 class buffertexture : public buffer<GL_TEXTURE_BUFFER, GL_STREAM_DRAW>, public texture<GL_TEXTURE_BUFFER> {
22 public:
23  buffertexture() :
25  {
26  data( 0, nullptr );
27  texture::bind();
28  check_gl_error( glTexBuffer( GL_TEXTURE_BUFFER, InternalFormat, buffer::name() ) );
30  }
31 
38  GLuint buffer_name() const {
39  return buffer::name();
40  }
41 
48  GLuint texture_name() const {
49  return texture::name();
50  }
51 
59  void bind() {
60  texture::bind();
61  }
62 
67  static void unbind() {
69  }
70 };
71 
72 }
73 
GLuint name() const
Retrieve the OpenGL name of this texture.
Definition: texture.hpp:47
GLuint texture_name() const
Retrieve the OpenGL name of the texture.
Definition: buffertexture.hpp:48
void data(T data_size, const GLvoid *data_ptr)
Allocate storage and upload data.
Definition: buffer.hpp:112
Class encapsulating an OpenGL buffer object.
Definition: buffer.hpp:27
GLuint name() const
Retrieve the OpenGL name of this buffer.
Definition: buffer.hpp:35
void bind()
Bind this buffer texture.
Definition: buffertexture.hpp:59
Class encapsulating an OpenGL buffer object.
Definition: buffertexture.hpp:21
GLuint buffer_name() const
Retrieve the OpenGL name of the buffer.
Definition: buffertexture.hpp:38
static void unbind()
Unbind the current texture from the target.
Definition: texture.hpp:99
void bind()
Bind this texture to its target.
Definition: texture.hpp:88
static void unbind()
Unbind the current buffer texture.
Definition: buffertexture.hpp:67
Definition: buffer.hpp:12
Class encapsulating an OpenGL texture object.
Definition: texture.hpp:26