|
cangine
|
Wraps an OpenGL texture object. More...
#include <texture.hpp>
Public Member Functions | |
| Texture () | |
| Constructs an empty texture without loading any data. | |
| Texture (std::string path) | |
| Constructs a texture from an image file path (not yet loaded). | |
| void | createFromBuffer (int width, int height, unsigned char *data, bool mono=false) |
| Creates a texture from a raw pixel buffer. | |
| void | update (std::string path) |
| Replaces the texture's source image and reloads it. | |
| void | load () |
| Loads the image at path into GPU memory. | |
| void | bind () |
| Binds this texture for sampling. | |
| void | unbind () |
| Unbinds the current texture. | |
Public Attributes | |
| unsigned int | ID |
| OpenGL texture object handle. | |
| std::string | path |
Wraps an OpenGL texture object.
Can be created from an image file on disk or from a raw pixel buffer (e.g. a glyph atlas), then bound for sampling in a shader.
| cangine::Texture::Texture | ( | ) |
Constructs an empty texture without loading any data.
| cangine::Texture::Texture | ( | std::string | path | ) |
Constructs a texture from an image file path (not yet loaded).
| path | Path to the image file. |
| void cangine::Texture::bind | ( | ) |
Binds this texture for sampling.
| void cangine::Texture::createFromBuffer | ( | int | width, |
| int | height, | ||
| unsigned char * | data, | ||
| bool | mono = false |
||
| ) |
Creates a texture from a raw pixel buffer.
| width | Width of the buffer in pixels. |
| height | Height of the buffer in pixels. |
| data | Pointer to the pixel data. |
| mono | If true, treat the data as a single-channel image. |
| void cangine::Texture::load | ( | ) |
Loads the image at path into GPU memory.
| void cangine::Texture::unbind | ( | ) |
Unbinds the current texture.
| void cangine::Texture::update | ( | std::string | path | ) |
Replaces the texture's source image and reloads it.
| path | Path to the new image file. |
| unsigned int cangine::Texture::ID |
OpenGL texture object handle.
| std::string cangine::Texture::path |
Path of the source image, if loaded from a file.