BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
Texture Struct Reference

A structure that stores a texture file that has been read into the OpenGL context. More...

Inheritance diagram for Texture:
Collaboration diagram for Texture:

Public Member Functions

bool IsInternal ()
 Returns whether the texture is for internal use only.
 
 Texture (const std::string &name, const std::string &scope, TextureType type, const std::string &dir, const std::string &filename, bool flip=true, bool internal=false)
 Loads a new texture from the given file.
 
 Texture (const std::string &name, const std::string &scope, unsigned int id, TextureType type=TextureType::DIFFUSE, const std::string &dir="", const std::string &filename="", bool internal=false)
 Creates a new instance of a texture that is already loaded into OpenGL.
 
 Texture (const std::string &name="", const std::string &scope="", TextureType type=TextureType::DIFFUSE, const glm::vec3 &color=glm::vec3(1.0f), bool internal=false)
 Creates a new texture from the given color.
 
- Public Member Functions inherited from ISelectable
virtual SelectableType GetSelectableType ()
 Returns the type of the selectable.
 
 ISelectable (SelectableType type=SelectableType::NONE)
 Sets the type of the selectable.
 
- Public Member Functions inherited from INameable
virtual void Rename (const std::string &newName, bool includeScope=true)
 Renames the object, setting the scope to be the scoped part of the name.
 
virtual void SetName (const std::string &name)
 Sets the name of the object. Note: Does not set the scope variable. If renaming based on raw input, use Rename() instead to set the scope.
 
virtual void SetScope (const std::string &scope)
 Sets the scope of the object.
 
std::string GetUnscopedName ()
 Returns the unscoped name of the object.
 
std::string GetScope ()
 Returns the scope of the object.
 
std::string GetScopedName ()
 Returns the scoped name of the object.
 
void InitName (const std::string &name, const std::string &scope="")
 Initializes the nameable object with the given name and scope.
 
 INameable ()
 Creates a default nameable object without name or scope.
 

Static Public Member Functions

static std::string TextureToTypeString (TextureType type)
 Casts the given texture type into its shader equivalent string.
 
static std::string TextureTypeToDisplayString (TextureType type)
 Converts the texture type to a display-friendly string representation.
 
static unsigned int TextureFromColor (const glm::vec3 &color)
 Generates a runtime texture from the given solid color.
 
static unsigned int TextureFromFile (const std::string &directory, const std::string &filename, bool flip=true)
 Loads the given texture from a file.
 
static unsigned int TextureFromFile (const std::string &directory, const std::string &filename, int &outWidth, int &outHeight, bool flip=true)
 Loads the given texture from a file.
 
static void CopyTexture (const std::string &file, const std::string &fromDir, const std::string &toDir, bool flip=true)
 Moves a copy of the texture from the start directory to the end directory.
 

Public Attributes

unsigned int mID
 OpenGL texture index.
 
std::string mFile
 The filename of the texture.
 
std::string mDir
 The path of the directory for the texture.
 
TextureType mType
 The type of the texture.
 

Additional Inherited Members

- Protected Attributes inherited from ISelectable
SelectableType mSelectableType = SelectableType::NONE
 Type of the selectable.
 
- Protected Attributes inherited from INameable
std::string mName = ""
 Name of the object.
 
std::string mScope = ""
 Scope of the object.
 

Detailed Description

A structure that stores a texture file that has been read into the OpenGL context.

Constructor & Destructor Documentation

◆ Texture() [1/3]

Texture::Texture ( const std::string &  name,
const std::string &  scope,
TextureType  type,
const std::string &  dir,
const std::string &  filename,
bool  flip = true,
bool  internal = false 
)
inline

Loads a new texture from the given file.

Parameters
nameName of the texture
scopeScope of the texture
typeType of the texture
dirPath of the referenced texture file
filenameName of the texture
flipWhether to flip the texture vertically
internalWhether the texture is internal only

◆ Texture() [2/3]

Texture::Texture ( const std::string &  name,
const std::string &  scope,
unsigned int  id,
TextureType  type = TextureType::DIFFUSE,
const std::string &  dir = "",
const std::string &  filename = "",
bool  internal = false 
)
inline

Creates a new instance of a texture that is already loaded into OpenGL.

Parameters
nameName of the texture
scopeScope of the texture
idOpenGL textureID index
typeTexture type
dirPath of the referenced texture file
filenameName of the texture
internalWhether the texture is internal only

◆ Texture() [3/3]

Texture::Texture ( const std::string &  name = "",
const std::string &  scope = "",
TextureType  type = TextureType::DIFFUSE,
const glm::vec3 &  color = glm::vec3(1.0f),
bool  internal = false 
)
inline

Creates a new texture from the given color.

Parameters
nameName of the texture
scopeScope of the texture
typeType of the texture
colorColor of the texture
internalWhether the texture is internal only

Member Function Documentation

◆ CopyTexture()

static void Texture::CopyTexture ( const std::string &  file,
const std::string &  fromDir,
const std::string &  toDir,
bool  flip = true 
)
inlinestatic

Moves a copy of the texture from the start directory to the end directory.

Parameters
fileFilename to copy
fromDirStart directory
toDirEnd directory
flipWhether to flip the texture vertically

◆ IsInternal()

bool Texture::IsInternal ( )
inline

Returns whether the texture is for internal use only.

Returns
Whether the texture is for internal use

◆ TextureFromColor()

static unsigned int Texture::TextureFromColor ( const glm::vec3 &  color)
inlinestatic

Generates a runtime texture from the given solid color.

Parameters
color
name
Returns

◆ TextureFromFile() [1/2]

static unsigned int Texture::TextureFromFile ( const std::string &  directory,
const std::string &  filename,
bool  flip = true 
)
inlinestatic

Loads the given texture from a file.

Parameters
directoryDirectory of the texture
filenameFilename of the texture
gammaWhether to gamma correct the texture
flipWhether to flip the texture vertically
Returns
OpenGL index of the texture

◆ TextureFromFile() [2/2]

static unsigned int Texture::TextureFromFile ( const std::string &  directory,
const std::string &  filename,
int &  outWidth,
int &  outHeight,
bool  flip = true 
)
inlinestatic

Loads the given texture from a file.

Parameters
directoryDirectory of the texture
filenameFilename of the texture
out_widthReturn width of the texture
out_heightReturn height of the texture
gammaWhether to gamma correct the texture
flipWhether to flip the texture vertically
Returns
OpenGL index of the texture

◆ TextureToTypeString()

static std::string Texture::TextureToTypeString ( TextureType  type)
inlinestatic

Casts the given texture type into its shader equivalent string.

Parameters
typeTexture Type
Returns
Shader texture type

◆ TextureTypeToDisplayString()

static std::string Texture::TextureTypeToDisplayString ( TextureType  type)
inlinestatic

Converts the texture type to a display-friendly string representation.

Parameters
typeTexture type
Returns
Display-friendly string representation of the texture type

Member Data Documentation

◆ mDir

std::string Texture::mDir

The path of the directory for the texture.

◆ mFile

std::string Texture::mFile

The filename of the texture.

◆ mID

unsigned int Texture::mID

OpenGL texture index.

◆ mType

TextureType Texture::mType

The type of the texture.