BARE2D
GLContextManager.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <GL/gl.h>
4 
5 namespace BARE2D {
6 
7  class GLContext {
8  public:
9  GLContext();
10  ~GLContext();
11  /**
12  * @brief Sets the active texture "slot". This can be GL_TEXTURE0 to GL_TEXTURE8 (I think. Check the literature)
13  * @param texture The texture slot to tell OpenGL is "active"
14  */
15  void setActiveTexture(GLenum texture);
16 
17  /**
18  * @brief Binds a texture to target in the currently active texture slot
19  * @param target The target to bind to
20  * @param texture The id of a texture.
21  */
22  void bindTexture(GLenum target, GLenum texture);
23 
24  /**
25  * @brief Unbinds a texture
26  * @param target The target (GL_TEXTURE_2D generally)
27  * @param textureslot The texture to be unbound (GL_TEXTURE0-8)
28  */
29  void unbindTexture(GLenum target, GLenum textureslot);
30 
31  GLuint getBoundTexture();
32 
33  private:
34  // The active texture "slot"
35  GLenum m_activeTexture = GL_TEXTURE0;
36 
37  // Holds a bound texture for each texture "slot" there is in OpenGL (1 for GL_TEXTURE0, 1 for GL_TEXTURE1, etc.)
38  GLuint* m_boundTextureIDs = nullptr;
39  };
40 
41 
43  {
44  public:
45  static GLContext* getContext();
46 
47  private:
49 
50  };
51 
52 }
53 
BARE2D
Definition: App.cpp:13
BARE2D::GLContext::m_activeTexture
GLenum m_activeTexture
Definition: GLContextManager.hpp:35
BARE2D::GLContext::bindTexture
void bindTexture(GLenum target, GLenum texture)
Binds a texture to target in the currently active texture slot.
Definition: GLContextManager.cpp:22
BARE2D::GLContext::getBoundTexture
GLuint getBoundTexture()
Definition: GLContextManager.cpp:37
BARE2D::GLContext::unbindTexture
void unbindTexture(GLenum target, GLenum textureslot)
Unbinds a texture.
Definition: GLContextManager.cpp:32
BARE2D::GLContext::GLContext
GLContext()
Definition: GLContextManager.cpp:5
BARE2D::GLContext
Definition: GLContextManager.hpp:7
BARE2D::GLContext::setActiveTexture
void setActiveTexture(GLenum texture)
Sets the active texture "slot". This can be GL_TEXTURE0 to GL_TEXTURE8 (I think. Check the literature...
Definition: GLContextManager.cpp:13
BARE2D::GLContextManager::m_context
static GLContext * m_context
Definition: GLContextManager.hpp:48
BARE2D::GLContext::~GLContext
~GLContext()
Definition: GLContextManager.cpp:9
BARE2D::GLContextManager::getContext
static GLContext * getContext()
Definition: GLContextManager.cpp:44
BARE2D::GLContextManager
Definition: GLContextManager.hpp:42
BARE2D::GLContext::m_boundTextureIDs
GLuint * m_boundTextureIDs
Definition: GLContextManager.hpp:38