BARE2D
MutableTexture.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <GL/glew.h>
4 
5 #include "Texture.hpp"
6 
7 namespace BARE2D {
8 
9  /**
10  * @class MutableTexture
11  * @brief A child of Texture which allows (and gives helpful functions for) mutation.
12  */
13  struct MutableTexture : public Texture {
14  /**
15  * @brief Sets the data of the mutable texture, as well as updates the OpenGL context's texture data for it (uses glTextureSubImage2D).
16  * @param data The data (formatted R0,G0,B0,A0,R1,G1,B1,A0,etc.). Assumes width and height of data are equal to that of the texture.
17  * @param format The format of the data. Must follow OpenGL Formats (GL_RED, GL_RG, etc.). Defaults to GL_RGBA
18  */
19  void setData(unsigned char* data);
20 
21  /**
22  * @brief Sets the data of the mutable texture, as well as updates the OpenGL context's texture data for it (uses glTextureSubImage2D).
23  * @param data The data (default formatted R0,G0,B0,A0,R1,G1,B1,A0,etc.).
24  * @param xOffset How far in from the x side the texture should be overwritten
25  * @param yOffset How far in from the y side the texture should be overwritten
26  * @param width The width of the data
27  * @param height The height of the data
28  * @param format The format of the data. Must follow OpenGL Formats (GL_RED, GL_RG, etc.). Defaults to GL_RGBA
29  */
30  void setData(unsigned char* data,
31  unsigned int xOffset,
32  unsigned int yOffset,
33  unsigned int subWidth,
34  unsigned int subHeight);
35 
36  GLenum format = GL_RGBA;
37  unsigned int channels = 4;
38  };
39 
40 } // namespace BARE2D
BARE2D
Definition: App.cpp:13
BARE2D::Texture
The texture struct holds very basic stuff - the filepath, width, height, and ID,.
Definition: Texture.hpp:13
BARE2D::MutableTexture::channels
unsigned int channels
Definition: MutableTexture.hpp:37
BARE2D::MutableTexture
A child of Texture which allows (and gives helpful functions for) mutation.
Definition: MutableTexture.hpp:13
BARE2D::MutableTexture::format
GLenum format
Definition: MutableTexture.hpp:36
BARE2D::MutableTexture::setData
void setData(unsigned char *data)
Sets the data of the mutable texture, as well as updates the OpenGL context's texture data for it (us...
Definition: MutableTexture.cpp:9
Texture.hpp