|
GlistEngine
|
#include <gImage.h>


Public Member Functions | |
| gImage () | |
| gImage (int w, int h, int format=GL_RGBA) | |
| gImage (const gImage &other) | |
| gImage (gImage &&other) noexcept | |
| gImage & | operator= (const gImage &other) |
| gImage & | operator= (gImage &&other) noexcept |
| virtual | ~gImage () |
| unsigned int | load (const std::string &fullPath) |
| unsigned int | loadImage (const std::string &imagePath) |
| unsigned int | loadImageFromURL (const std::string &imageUrl) |
| unsigned int | loadImageFromURL (const std::string &imageUrl, bool cutUrlParameters) |
| void | loadData (const std::string &fullPath) |
| void | loadImageData (const std::string &imagePath) |
| unsigned int | useData () |
| void | setImageData (unsigned char *imageData) |
| void | setImageData (unsigned char *imageData, int width, int height, int componentNum, bool isMutable=false, bool isStbImage=false) |
| unsigned char * | getImageData () |
| void | setImageDataHDR (float *imageData) |
| void | setImageDataHDR (float *imageData, int width, int height, int componentNum, bool isMutable=false, bool isStbImage=false) |
| float * | getImageDataHDR () |
| void | clearData () |
| void | save (std::string fullpath) |
| void | saveImage (std::string fileName) |
| bool | checkPixelPerfectCollision (gImage *otherImage, float imgposX, float imgposY, float otherimgposX, float otherimgposY) |
| std::string | getImageUrl () |
| unsigned int | loadMaskImage (const std::string &maskImagePath) |
Public Member Functions inherited from gTexture | |
| gTexture () | |
| gTexture (int w, int h, int format=GL_RGBA, bool isFbo=false) | |
| gTexture (const gTexture &other) | |
| gTexture (gTexture &&other) noexcept | |
| gTexture & | operator= (const gTexture &other) |
| gTexture & | operator= (gTexture &&other) noexcept |
| virtual | ~gTexture () |
| unsigned int | loadTexture (const std::string &texturePath) |
| unsigned int | loadMask (const std::string &fullPath) |
| unsigned int | loadMaskTexture (const std::string &maskTexturePath) |
| 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 (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 (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 (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 std::string | generateDownloadedImagePath (std::string imageType="png") |
Static Public Member Functions inherited from gTexture | |
| 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 gRenderer * | getRenderer () |
| static void | destroyRenderer () |
| static void | createRenderer () |
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 | copyFrom (const gImage &other) noexcept |
| void | swap (gImage &other) noexcept |
Protected Member Functions inherited from gTexture | |
| 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) |
gImage holds several functions primarily to locate and load images.
Overview of the functions: load and loadImage functions to load images effectively. loadData and loadImageData functions to load image's Data in a separate thread. useData function to create the texture in VRAM by using the loaded data. setImageData function to alter an image's data in integer format. setImageDataHDR function to alter an image's data in float format. getImageData function to access an image's original or edited data in integer format. getImageDataHDR function to access an image's original or edited data in float format. clearData function to clear a given Data.
| gImage::gImage | ( | ) |
| gImage::gImage | ( | int | w, |
| int | h, | ||
| int | format = GL_RGBA |
||
| ) |
| gImage::gImage | ( | const gImage & | other | ) |
|
noexcept |
|
virtual |
| bool gImage::checkPixelPerfectCollision | ( | gImage * | otherImage, |
| float | imgposX, | ||
| float | imgposY, | ||
| float | otherimgposX, | ||
| float | otherimgposY | ||
| ) |
Used to check pixel perfect collision between 2 images.
| OtherImage | for the target image object which will be checked collisions with the caller object. positions of this images and position of the target image rotations of this images and rotation of the target image |
| void gImage::clearData | ( | ) |
Clears the data of a given structure.
|
protectednoexcept |
|
static |
| unsigned char * gImage::getImageData | ( | ) |
Accesses an image's original or edited data in integer format. The data should be loaded in order to be accessed by this function.
| float * gImage::getImageDataHDR | ( | ) |
Accesses an image's original or edited data in float format. The data should be loaded in order to be accessed by this function.
| std::string gImage::getImageUrl | ( | ) |
|
virtual |
Loads an image from the given fullpath.
Supported image formats can be found in the class description.
The image might be stored anywhere on the hard disk or other storage devices out of the project folder.
This function was created primarily for development purposes. Due to the difficulties and errors of storing images in a messy fashion, developers are encouraged to use the loadImage function instead.
| fullPath | The full path to the image 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. |
Reimplemented from gTexture.
| void gImage::loadData | ( | const std::string & | fullPath | ) |
Loads an image's data from the given full path to the RAM.
Supported image formats can be found in the class description.
The image can be located in anywhere(hard disk or other storage devices) as long as it has the full path.Supported image formats can be found in the class description.
Loading assets in separate threads improves overall efficiency. In order to load an image's data separately, this function can be used. It doesn't create a texture of the loaded data's image in VRAM, instead it loads the Data of a given image and saves it into the RAM.
| fullPath | The full path to the image file. It should contain the full path of the folder where the image is located. |
| unsigned int gImage::loadImage | ( | const std::string & | imagePath | ) |
Loads an image from the project's images folder.
Supported image formats can be found in the class description.
There is no need to enter the folder address, as the function loads from the project's own images folders. It is only necessary to specify the name and extension of the image. For example, giving an address such as "image.jpg" is sufficient. Make sure that the named image is placed in the project's images folder.
Project's default images folder is ProjectLocation/assets/images directory.
The project's image folder may vary depending on the project's scaling settings. In case of SCALING_NONE and SCALING_AUTO, this function loads images from ProjectLocation/assets/images folder. In case of SCALING_MIPMAP, ProjectLocation/assets/mipmaps/DeviceResolution folder becomes images folder.
Developers are encouraged to use this function for image loading so that an efficient and shareable work can be carried out.
| imagePath | The fullname of the image stored under project's images folder. Fullname should contain image name and its extension. It is case sensitive. |
| void gImage::loadImageData | ( | const std::string & | imagePath | ) |
Loads an image's data from the project's images folder to the RAM.
Supported image formats can be found in the class description.
It doesn't require a full path of an image because the function loads an image from the project's own images folders. In fact, providing this function with a path that looks like 'image.jpg' is sufficient.
Project's default images folder is ProjectLocation/assets/images directory.
Loading assets in separate threads improves overall efficiency. In order to load an image's data separately, this function can be used. It doesn't create a texture of the loaded data's image in VRAM, instead it loads the Data of a given image and saves it into the RAM.
Developers are encouraged to use this function for Data loading so that an efficient work can be carried out.
| ImagePath | The full name of the image stored under project's images folder which should contain the image name and its extension. It is case sensitive. |
| unsigned int gImage::loadImageFromURL | ( | const std::string & | imageUrl | ) |
| unsigned int gImage::loadImageFromURL | ( | const std::string & | imageUrl, |
| bool | cutUrlParameters | ||
| ) |
| unsigned int gImage::loadMaskImage | ( | const std::string & | maskImagePath | ) |
| void gImage::save | ( | std::string | fullpath | ) |
Used for the image's extension and changing image's name.
| fileName | is a string value for the function . This file will be exist in the GlistApp's assets clasor after saving process. |
| void gImage::saveImage | ( | std::string | fileName | ) |
| void gImage::setImageData | ( | unsigned char * | imageData | ) |
Alters an image's data in integer format.
Data of a given image can be altered by the usage of this function. It's in integer format.
| void gImage::setImageData | ( | unsigned char * | imageData, |
| int | width, | ||
| int | height, | ||
| int | componentNum, | ||
| bool | isMutable = false, |
||
| bool | isStbImage = false |
||
| ) |
| void gImage::setImageDataHDR | ( | float * | imageData | ) |
Alters an image's data in float format.
Data of a given image can be altered by the usage of this function. It's in float format.
| void gImage::setImageDataHDR | ( | float * | imageData, |
| int | width, | ||
| int | height, | ||
| int | componentNum, | ||
| bool | isMutable = false, |
||
| bool | isStbImage = false |
||
| ) |
|
protectednoexcept |
| unsigned int gImage::useData | ( | ) |
Creates a texture in VRAM by the usage of loaded data.