13 Texture* Texture::current =
nullptr;
16 glGenTextures(1, &handle);
20 glDeleteTextures(1, &handle);
23 if (Texture::current ==
this) {
24 Texture::current =
nullptr;
42 if (Texture::current ==
this) {
47 glBindTexture(GL_TEXTURE_2D, handle);
48 Texture::current =
this;
52 glGenerateMipmap(GL_TEXTURE_2D);
56 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
to_GLint(filter));
60 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
to_GLint(filter));
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
to_GLint(wrap));
68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
to_GLint(wrap));
73 this->height = height;
74 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
This structure stores texture image data.
~Texture(void)
Deletes the texture object.
unsigned char * pixels
The pixel data of the image.
void bind()
Binds the texture object.
int height
The height of the image.
void setWrapS(TextureWrap wrap)
Sets the wrapping function of the texture object's coordinate S.
void setMagFilter(TextureFilter filter)
Sets the magnification filter of the texture object.
Texture(void)
Generates a new texture object.
void setWrapT(TextureWrap wrap)
Sets the wrapping function of the texture object's coordinate T.
void generateMipMap()
Generates mipmaps for the texture object.
Generic namespace for the SimpleGL framework.
int getWidth()
Returns the width of the texture object.
TextureWrap
This enum wraps the texture object's wrapping functions.
GLuint getHandle()
Returns the handle of the texture object.
TextureFilter
This enum wraps the texture object's filter.
GLint to_GLint(E e)
Gets the GLint value from an enum class.
void uploadImage(int width, int height, unsigned char *data)
Uploads image data to the texture object.
void setMinFilter(TextureFilter filter)
Sets the minification filter of the texture object.
int getHeight()
Returns the height of the texture object.
int width
The width of the image.