cangine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cangine::Texture Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Texture() [1/2]

cangine::Texture::Texture ( )

Constructs an empty texture without loading any data.

◆ Texture() [2/2]

cangine::Texture::Texture ( std::string  path)

Constructs a texture from an image file path (not yet loaded).

Parameters
pathPath to the image file.

Member Function Documentation

◆ bind()

void cangine::Texture::bind ( )

Binds this texture for sampling.

◆ createFromBuffer()

void cangine::Texture::createFromBuffer ( int  width,
int  height,
unsigned char *  data,
bool  mono = false 
)

Creates a texture from a raw pixel buffer.

Parameters
widthWidth of the buffer in pixels.
heightHeight of the buffer in pixels.
dataPointer to the pixel data.
monoIf true, treat the data as a single-channel image.

◆ load()

void cangine::Texture::load ( )

Loads the image at path into GPU memory.

◆ unbind()

void cangine::Texture::unbind ( )

Unbinds the current texture.

◆ update()

void cangine::Texture::update ( std::string  path)

Replaces the texture's source image and reloads it.

Parameters
pathPath to the new image file.

Member Data Documentation

◆ ID

unsigned int cangine::Texture::ID

OpenGL texture object handle.

◆ path

std::string cangine::Texture::path

Path of the source image, if loaded from a file.


The documentation for this class was generated from the following files: