Brenta Engine 1.2
Loading...
Searching...
No Matches
brenta::texture Class Reference

Texture class. More...

#include <texture.hpp>

Public Member Functions

 texture ()
 Empty constructor, does nothing.
 
 texture (const std::string &path, bool flip=true, const std::string &type="texture_diffuse")
 Creates a new tecture.
 
constexpr texture (texture &&other) noexcept
 
constexpr textureoperator= (texture &&other) noexcept
 
unsigned int get_id () const
 
void bind (GLenum target, GLint wrapping=GL_REPEAT, GLint filtering_min=GL_NEAREST, GLint filtering_mag=GL_NEAREST, GLboolean has_mpmap=GL_TRUE, GLint mipmap_min=GL_LINEAR_MIPMAP_LINEAR, GLint mipmap_mag=GL_LINEAR)
 

Static Public Member Functions

static void active_texture (GLenum texture)
 Activate a texture unit.
 
static unsigned int load (const std::string &path, bool flip=true)
 Load a texture from a file.
 
static void bind_id (GLenum target, unsigned int id, GLint wrapping=GL_REPEAT, GLint filtering_min=GL_NEAREST, GLint filtering_mag=GL_NEAREST, GLboolean has_mipmap=GL_TRUE, GLint mipmap_min=GL_LINEAR_MIPMAP_LINEAR, GLint mipmap_mag=GL_LINEAR)
 Bind a texture.
 

Data Fields

unsigned int id
 
std::string type
 
std::string path
 

Detailed Description

Texture class.

This class is used to load and manage textures.

Definition at line 19 of file texture.hpp.

Constructor & Destructor Documentation

◆ texture() [1/3]

brenta::texture::texture ( )
inline

Empty constructor, does nothing.

Definition at line 64 of file texture.hpp.

◆ texture() [2/3]

texture::texture ( const std::string &  path,
bool  flip = true,
const std::string &  type = "texture_diffuse" 
)

Creates a new tecture.

Parameters
pathPath to the texture file
flipWhether the texture sould be flipped or not
typeAn optional string that may be used by other systems

Definition at line 15 of file texture.cpp.

◆ texture() [3/3]

constexpr brenta::texture::texture ( texture &&  other)
inlineconstexprnoexcept

Definition at line 75 of file texture.hpp.

◆ ~texture()

texture::~texture ( )

Definition at line 25 of file texture.cpp.

Member Function Documentation

◆ active_texture()

void texture::active_texture ( GLenum  texture)
static

Activate a texture unit.

This method activates a texture unit. Arg is GL_TEXTURE0 + x

Definition at line 39 of file texture.cpp.

◆ bind()

void texture::bind ( GLenum  target,
GLint  wrapping = GL_REPEAT,
GLint  filtering_min = GL_NEAREST,
GLint  filtering_mag = GL_NEAREST,
GLboolean  has_mpmap = GL_TRUE,
GLint  mipmap_min = GL_LINEAR_MIPMAP_LINEAR,
GLint  mipmap_mag = GL_LINEAR 
)

Definition at line 64 of file texture.cpp.

◆ bind_id()

void texture::bind_id ( GLenum  target,
unsigned int  id,
GLint  wrapping = GL_REPEAT,
GLint  filtering_min = GL_NEAREST,
GLint  filtering_mag = GL_NEAREST,
GLboolean  has_mipmap = GL_TRUE,
GLint  mipmap_min = GL_LINEAR_MIPMAP_LINEAR,
GLint  mipmap_mag = GL_LINEAR 
)
static

Bind a texture.

This method binds a texture to a target. The texture is bound with the specified wrapping and filtering modes.

You need to bind the texture before using it in the shader.

Definition at line 53 of file texture.cpp.

◆ get_id()

unsigned int texture::get_id ( ) const

Definition at line 34 of file texture.cpp.

◆ load()

unsigned int texture::load ( const std::string &  path,
bool  flip = true 
)
static

Load a texture from a file.

This method loads a texture from a file and returns the texture ID. The texture is loaded using the stb_image library.

Parameters
pathPath to the texture file
Returns
The texture ID

Definition at line 44 of file texture.cpp.

◆ operator=()

constexpr texture & brenta::texture::operator= ( texture &&  other)
inlineconstexprnoexcept

Definition at line 83 of file texture.hpp.

Field Documentation

◆ id

unsigned int brenta::texture::id

Definition at line 23 of file texture.hpp.

◆ path

std::string brenta::texture::path

Definition at line 25 of file texture.hpp.

◆ type

std::string brenta::texture::type

Definition at line 24 of file texture.hpp.


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