GlistEngine
Loading...
Searching...
No Matches
gTexture Class Reference

#include <gTexture.h>

Inheritance diagram for gTexture:
Collaboration diagram for gTexture:

Public Types

enum  TextureType : int {
  TEXTURETYPE_DIFFUSE = 0 , TEXTURETYPE_SPECULAR = 1 , TEXTURETYPE_NORMAL = 2 , TEXTURETYPE_HEIGHT = 3 ,
  TEXTURETYPE_PBR_ALBEDO = 4 , TEXTURETYPE_PBR_ROUGHNESS = 5 , TEXTURETYPE_PBR_METALNESS = 6 , TEXTURETYPE_PBR_NORMAL = 7 ,
  TEXTURETYPE_PBR_AO = 8 , TEXTURETYPE_COUNT
}
enum  TextureWrap : int { TEXTUREWRAP_REPEAT = 0 , TEXTUREWRAP_CLAMP = 1 , TEXTUREWRAP_CLAMPTOEDGE = 2 , TEXTUREWRAP_NEAREST = 3 }
enum  TextureMagFilter : int { TEXTUREMINMAGFILTER_LINEAR = 0 , TEXTUREMINMAGFILTER_MIPMAPLINEAR = 1 , TEXTUREMINMAGFILTER_NEAREST = 2 , TEXTUREMINMAGFILTER_CLAMP = 3 }
enum  MaskMode : int { MASKMODE_BOTH = 0 , MASKMODE_PICTURE = 1 , MASKMODE_MASK = 2 , MASKMODE_BOTH_FREE_ROTATE = 3 }

Public Member Functions

 gTexture ()
 gTexture (int w, int h, int format=GL_RGBA, bool isFbo=false)
 gTexture (const gTexture &other)
 gTexture (gTexture &&other) noexcept
 gTexture (int w, int h, int miplevels, int format, bool isFbo)
gTexture & operator= (const gTexture &other)
gTexture & operator= (gTexture &&other) noexcept
virtual ~gTexture ()
virtual unsigned int load (const std::string &fullPath)
unsigned int loadTexture (const std::string &texturePath)
unsigned int loadMask (const std::string &fullPath)
unsigned int loadMaskTexture (const std::string &maskTexturePath)
void setMaskMode (int maskMode)
void setMaskRotation (float angle)
void setImageRotation (float angle)
void setObjectRotation (float angle)
void setAlphaMasking (int maskMode)
void disableAlphaMasking ()
bool getAlphaMasking () const
void bind () const
void bind (int textureSlotNo) const
void unbind () const
unsigned int getId () const
bool isHDR () const
unsigned int getInternalFormat () const
unsigned int getFormat () const
void setType (TextureType textureType)
TextureType getType () const
void setWrapping (int wrapS, int wrapT)
void setFiltering (int minFilter, int magFilter)
int getWrapS () const
int getWrapT () const
int getFilterMin () const
int getFilterMag () const
const std::string & getTypeName () const
const std::string & getFilename () const
const std::string & getDir () const
const std::string & getFullPath () const
int getWidth () const
int getHeight () const
int getComponentNum () const
void draw (int x, int y)
void draw (int x, int y, int w, int h)
void draw (int x, int y, int w, int h, float rotate)
void draw (int x, int y, int w, int h, int pivotx, int pivoty, float rotate)
void draw (int x, int y, int w, int h, int pivotx, int pivoty, float rotate, bool flipHorizontal)
void draw (glm::vec2 position, glm::vec2 size, float rotate=0.0f)
void draw (glm::vec2 position, glm::vec2 size, glm::vec2 pivot, float rotate=0.0f)
void drawSub (int x, int y, int sx, int sy, int sw, int sh)
void drawSub (int x, int y, int w, int h, int sx, int sy, int sw, int sh)
void drawSub (int x, int y, int w, int h, int sx, int sy, int sw, int sh, float rotate)
void drawSub (int x, int y, int w, int h, int sx, int sy, int sw, int sh, int pivotx, int pivoty, float rotate)
void drawSub (int x, int y, int w, int h, int sx, int sy, int sw, int sh, int pivotx, int pivoty, float rotate, bool flipHorizontal)
void drawSub (glm::vec2 pos, glm::vec2 size, glm::vec2 subpos, glm::vec2 subsize, float rotate=0.0f)
void drawSub (glm::vec2 pos, glm::vec2 size, glm::vec2 subpos, glm::vec2 subsize, glm::vec2 pivot, float rotate=0.0f)
void drawSub (glm::vec2 pos, glm::vec2 size, glm::vec2 subpos, glm::vec2 subsize, glm::vec2 pivot, float rotate, bool flipHorizontal)
void drawSub (const gRect &src, const gRect &dst, float rotate=0.f)
void drawSub (const gRect &src, const gRect &dst, int pivotx, int pivoty, float rotate=0.f)
void drawSub (const gRect &src, const gRect &dst, glm::vec2 pivot, float rotate=0.f)
unsigned int setData (unsigned char *textureData, int width, int height, int componentNum, bool isMutable=false, bool isStbImage=false)
unsigned int setDataHDR (float *textureData, int width, int height, int componentNum, bool isMutable=false, bool isStbImage=false)
void setupRenderData ()
void cleanupData ()
void cleanupAll ()
void save (std::string fullpath)
void saveTexture (std::string fileName)
unsigned char * getData ()
Public Member Functions inherited from gRenderObject
 gRenderObject ()
int getScreenWidth ()
int getScreenHeight ()
void pushMatrix ()
void popMatrix ()
Public Member Functions inherited from gObject
 gObject ()
void logi (std::string message)
void logd (std::string message)
void logw (std::string message)
void loge (std::string message)
void logi (std::string tag, std::string message)
void logd (std::string tag, std::string message)
void logw (std::string tag, std::string message)
void loge (std::string tag, std::string message)

Static Public Member Functions

static const std::string & getTypeName (TextureType textureType)
Static Public Member Functions inherited from gRenderObject
static void setScreenSize (int screenWidth, int screenHeight)
static void setUnitScreenSize (int unitWidth, int unitHeight)
static void setScreenScaling (int screenScaling)
static void enableShadowMapping ()
static void disableShadowMapping ()
static bool isShadowMappingEnabled ()
static void enableExtraShaders (bool isEnabled=true)
static void disableExtraShaders ()
static bool isExtraShadersEnabled ()
static gRenderer * getRenderer ()
static void destroyRenderer ()
static void createRenderer (int renderEngine=G_RENDERER_GL)
Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
static std::string gGetAssetsDir ()
static void gSetAssetsDir (std::string assetsDir)
static std::string gGetFilesDir ()
static std::string gGetImagesDir ()
static std::string gGetFontsDir ()
static std::string gGetModelsDir ()
static std::string gGetTexturesDir ()
static std::string gGetShadersDir ()
static std::string gGetSoundsDir ()
static std::string gGetDatabasesDir ()
static std::string gGetVideosDir ()
static void setCurrentResolution (int scalingNo, int currentResolutionNo)

Protected Member Functions

void setDataInternal (unsigned char *textureData, bool isMutable=false, bool isStbImage=false, bool clean=true)
void setDataInternalHDR (float *textureData, bool isMutable=false, bool isStbImage=false, bool clean=true)
bool isMutable ()
void swap (gTexture &other) noexcept
void copyFrom (const gTexture &other) noexcept
std::string getDirName (const std::string &fname)
std::string getFileName (const std::string &fname)

Protected Attributes

std::string fullpath
std::string directory
unsigned int id
unsigned int internalformat
unsigned int format
TextureType type
std::string path
int width
int height
int componentnum
unsigned char * data
bool ismutable
bool isstbimage
int wraps
int wrapt
int filtermin
int filtermag
bool ishdr
float * datahdr
bool ismaskloaded
gTexture * masktexture
bool istextureallocated
int maskmode = MASKMODE_BOTH
float maskRotation = 0.0f
float imageRotation = 0.0f
float objectRotation = 0.0f
bool isalphamasking = false

Additional Inherited Members

Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
static const int LOGLEVEL_DEBUG
static const int LOGLEVEL_INFO
static const int LOGLEVEL_WARNING
static const int LOGLEVEL_ERROR
Static Protected Attributes inherited from gRenderObject
static bool isshadowmappingenabled
static bool isextrashadersenabled
Static Protected Attributes inherited from gObject
static int renderpassnum
static int renderpassno
static int releasescaling
static int releaseresolution

Member Enumeration Documentation

◆ MaskMode

enum gTexture::MaskMode : int
Enumerator
MASKMODE_BOTH 
MASKMODE_PICTURE 
MASKMODE_MASK 
MASKMODE_BOTH_FREE_ROTATE 

◆ TextureMagFilter

Enumerator
TEXTUREMINMAGFILTER_LINEAR 
TEXTUREMINMAGFILTER_MIPMAPLINEAR 
TEXTUREMINMAGFILTER_NEAREST 
TEXTUREMINMAGFILTER_CLAMP 

◆ TextureType

Enumerator
TEXTURETYPE_DIFFUSE 
TEXTURETYPE_SPECULAR 
TEXTURETYPE_NORMAL 
TEXTURETYPE_HEIGHT 
TEXTURETYPE_PBR_ALBEDO 
TEXTURETYPE_PBR_ROUGHNESS 
TEXTURETYPE_PBR_METALNESS 
TEXTURETYPE_PBR_NORMAL 
TEXTURETYPE_PBR_AO 
TEXTURETYPE_COUNT 

◆ TextureWrap

Enumerator
TEXTUREWRAP_REPEAT 
TEXTUREWRAP_CLAMP 
TEXTUREWRAP_CLAMPTOEDGE 
TEXTUREWRAP_NEAREST 

Constructor & Destructor Documentation

◆ gTexture() [1/5]

gTexture::gTexture ( )

◆ gTexture() [2/5]

gTexture::gTexture ( int w,
int h,
int format = GL_RGBA,
bool isFbo = false )

◆ gTexture() [3/5]

gTexture::gTexture ( const gTexture & other)

◆ gTexture() [4/5]

gTexture::gTexture ( gTexture && other)
noexcept

◆ gTexture() [5/5]

gTexture::gTexture ( int w,
int h,
int miplevels,
int format,
bool isFbo )

◆ ~gTexture()

virtual gTexture::~gTexture ( )
virtual

Member Function Documentation

◆ bind() [1/2]

void gTexture::bind ( ) const

◆ bind() [2/2]

void gTexture::bind ( int textureSlotNo) const

◆ cleanupAll()

void gTexture::cleanupAll ( )

◆ cleanupData()

void gTexture::cleanupData ( )

◆ copyFrom()

void gTexture::copyFrom ( const gTexture & other)
protectednoexcept

◆ disableAlphaMasking()

void gTexture::disableAlphaMasking ( )

◆ draw() [1/7]

void gTexture::draw ( glm::vec2 position,
glm::vec2 size,
float rotate = 0.0f )

◆ draw() [2/7]

void gTexture::draw ( glm::vec2 position,
glm::vec2 size,
glm::vec2 pivot,
float rotate = 0.0f )

◆ draw() [3/7]

void gTexture::draw ( int x,
int y )

◆ draw() [4/7]

void gTexture::draw ( int x,
int y,
int w,
int h )

◆ draw() [5/7]

void gTexture::draw ( int x,
int y,
int w,
int h,
float rotate )

◆ draw() [6/7]

void gTexture::draw ( int x,
int y,
int w,
int h,
int pivotx,
int pivoty,
float rotate )

◆ draw() [7/7]

void gTexture::draw ( int x,
int y,
int w,
int h,
int pivotx,
int pivoty,
float rotate,
bool flipHorizontal )

◆ drawSub() [1/11]

void gTexture::drawSub ( const gRect & src,
const gRect & dst,
float rotate = 0.f )

◆ drawSub() [2/11]

void gTexture::drawSub ( const gRect & src,
const gRect & dst,
glm::vec2 pivot,
float rotate = 0.f )

◆ drawSub() [3/11]

void gTexture::drawSub ( const gRect & src,
const gRect & dst,
int pivotx,
int pivoty,
float rotate = 0.f )

◆ drawSub() [4/11]

void gTexture::drawSub ( glm::vec2 pos,
glm::vec2 size,
glm::vec2 subpos,
glm::vec2 subsize,
float rotate = 0.0f )

◆ drawSub() [5/11]

void gTexture::drawSub ( glm::vec2 pos,
glm::vec2 size,
glm::vec2 subpos,
glm::vec2 subsize,
glm::vec2 pivot,
float rotate,
bool flipHorizontal )

◆ drawSub() [6/11]

void gTexture::drawSub ( glm::vec2 pos,
glm::vec2 size,
glm::vec2 subpos,
glm::vec2 subsize,
glm::vec2 pivot,
float rotate = 0.0f )

◆ drawSub() [7/11]

void gTexture::drawSub ( int x,
int y,
int sx,
int sy,
int sw,
int sh )

◆ drawSub() [8/11]

void gTexture::drawSub ( int x,
int y,
int w,
int h,
int sx,
int sy,
int sw,
int sh )

◆ drawSub() [9/11]

void gTexture::drawSub ( int x,
int y,
int w,
int h,
int sx,
int sy,
int sw,
int sh,
float rotate )

◆ drawSub() [10/11]

void gTexture::drawSub ( int x,
int y,
int w,
int h,
int sx,
int sy,
int sw,
int sh,
int pivotx,
int pivoty,
float rotate )

◆ drawSub() [11/11]

void gTexture::drawSub ( int x,
int y,
int w,
int h,
int sx,
int sy,
int sw,
int sh,
int pivotx,
int pivoty,
float rotate,
bool flipHorizontal )

◆ getAlphaMasking()

bool gTexture::getAlphaMasking ( ) const

◆ getComponentNum()

int gTexture::getComponentNum ( ) const

◆ getData()

unsigned char * gTexture::getData ( )

◆ getDir()

const std::string & gTexture::getDir ( ) const

◆ getDirName()

std::string gTexture::getDirName ( const std::string & fname)
protected

◆ getFileName()

std::string gTexture::getFileName ( const std::string & fname)
protected

◆ getFilename()

const std::string & gTexture::getFilename ( ) const

◆ getFilterMag()

int gTexture::getFilterMag ( ) const

◆ getFilterMin()

int gTexture::getFilterMin ( ) const

◆ getFormat()

unsigned int gTexture::getFormat ( ) const

◆ getFullPath()

const std::string & gTexture::getFullPath ( ) const

◆ getHeight()

int gTexture::getHeight ( ) const

◆ getId()

unsigned int gTexture::getId ( ) const

◆ getInternalFormat()

unsigned int gTexture::getInternalFormat ( ) const

◆ getType()

TextureType gTexture::getType ( ) const

◆ getTypeName() [1/2]

const std::string & gTexture::getTypeName ( ) const

◆ getTypeName() [2/2]

const std::string & gTexture::getTypeName ( TextureType textureType)
static

◆ getWidth()

int gTexture::getWidth ( ) const

◆ getWrapS()

int gTexture::getWrapS ( ) const

◆ getWrapT()

int gTexture::getWrapT ( ) const

◆ isHDR()

bool gTexture::isHDR ( ) const

◆ isMutable()

bool gTexture::isMutable ( )
protected

◆ load()

virtual unsigned int gTexture::load ( const std::string & fullPath)
virtual

Reimplemented in gImage.

◆ loadMask()

unsigned int gTexture::loadMask ( const std::string & fullPath)

Loads the mask texture/image to be applied to this instance.

It requires full path of the texture/image file.

The texture/image might be stored anywhere on the hard disk or other storage devices out of the project folder.

Parameters
fullPathThe full path to the image or texture file. It should contain the full path of the folder where the image is located, the name of the image and its extension. It is case sensitive.
Returns
Image id number generated by OpenGL.

◆ loadMaskTexture()

unsigned int gTexture::loadMaskTexture ( const std::string & maskTexturePath)

Loads the mask texture/image to be applied to this instance.

It requires the name of the texture/image file (ex: "mask.png").

The image might be stored anywhere on the hard disk or other storage devices out of the project folder.

Project's default folder for masks is ProjectLocation/assets/textures directory.

Parameters
maskTexturePathThe fullname of the texture/image stored under project's images folder. maskTexturePath should contain texture/image name and its extension. It is case sensitive.
Returns
Image id number generated by OpenGL.

◆ loadTexture()

unsigned int gTexture::loadTexture ( const std::string & texturePath)

◆ operator=() [1/2]

gTexture & gTexture::operator= ( const gTexture & other)

◆ operator=() [2/2]

gTexture & gTexture::operator= ( gTexture && other)
noexcept

◆ save()

void gTexture::save ( std::string fullpath)

◆ saveTexture()

void gTexture::saveTexture ( std::string fileName)

◆ setAlphaMasking()

void gTexture::setAlphaMasking ( int maskMode)

◆ setData()

unsigned int gTexture::setData ( unsigned char * textureData,
int width,
int height,
int componentNum,
bool isMutable = false,
bool isStbImage = false )

◆ setDataHDR()

unsigned int gTexture::setDataHDR ( float * textureData,
int width,
int height,
int componentNum,
bool isMutable = false,
bool isStbImage = false )

◆ setDataInternal()

void gTexture::setDataInternal ( unsigned char * textureData,
bool isMutable = false,
bool isStbImage = false,
bool clean = true )
protected

◆ setDataInternalHDR()

void gTexture::setDataInternalHDR ( float * textureData,
bool isMutable = false,
bool isStbImage = false,
bool clean = true )
protected

◆ setFiltering()

void gTexture::setFiltering ( int minFilter,
int magFilter )

◆ setImageRotation()

void gTexture::setImageRotation ( float angle)

◆ setMaskMode()

void gTexture::setMaskMode ( int maskMode)

◆ setMaskRotation()

void gTexture::setMaskRotation ( float angle)

◆ setObjectRotation()

void gTexture::setObjectRotation ( float angle)

◆ setType()

void gTexture::setType ( TextureType textureType)

◆ setupRenderData()

void gTexture::setupRenderData ( )

◆ setWrapping()

void gTexture::setWrapping ( int wrapS,
int wrapT )

◆ swap()

void gTexture::swap ( gTexture & other)
protectednoexcept

◆ unbind()

void gTexture::unbind ( ) const

Member Data Documentation

◆ componentnum

int gTexture::componentnum
protected

◆ data

unsigned char* gTexture::data
protected

◆ datahdr

float* gTexture::datahdr
protected

◆ directory

std::string gTexture::directory
protected

◆ filtermag

int gTexture::filtermag
protected

◆ filtermin

int gTexture::filtermin
protected

◆ format

unsigned int gTexture::format
protected

◆ fullpath

std::string gTexture::fullpath
protected

◆ height

int gTexture::height
protected

◆ id

unsigned int gTexture::id
protected

◆ imageRotation

float gTexture::imageRotation = 0.0f
protected

◆ internalformat

unsigned int gTexture::internalformat
protected

◆ isalphamasking

bool gTexture::isalphamasking = false
protected

◆ ishdr

bool gTexture::ishdr
protected

◆ ismaskloaded

bool gTexture::ismaskloaded
protected

◆ ismutable

bool gTexture::ismutable
protected

◆ isstbimage

bool gTexture::isstbimage
protected

◆ istextureallocated

bool gTexture::istextureallocated
protected

◆ maskmode

int gTexture::maskmode = MASKMODE_BOTH
protected

◆ maskRotation

float gTexture::maskRotation = 0.0f
protected

◆ masktexture

gTexture* gTexture::masktexture
protected

◆ objectRotation

float gTexture::objectRotation = 0.0f
protected

◆ path

std::string gTexture::path
protected

◆ type

TextureType gTexture::type
protected

◆ width

int gTexture::width
protected

◆ wraps

int gTexture::wraps
protected

◆ wrapt

int gTexture::wrapt
protected

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