SLProject 4.0.000
SLGLTexture Class Reference

Texture object for OpenGL texturing. More...

#include <SLGLTexture.h>

Inheritance diagram for SLGLTexture:
[legend]

Public Member Functions

 SLGLTexture ()
 Default ctor for all stack instances (not created with new) More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLVCol4f &colors, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, const SLstring &name="2D-Texture")
 ctor for 1D texture with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, SLint min_filter, SLint mag_filter, SLint wrapS, SLint wrapT, SLenum target=GL_TEXTURE_2D)
 ctor for empty 2D textures More...
 
 SLGLTexture (SLAssetManager *assetMgr, unsigned char *data, int width, int height, int cvtype, SLint min_filter, SLint mag_filter, SLTextureType type, SLint wrapS, SLint wrapT)
 ctor for 2D textures from byte pointer More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLstring &imageFilename, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT)
 ctor for 2D textures with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLVstring &imageFilenames, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT, const SLstring &name="3D-Texture", SLbool loadGrayscaleIntoAlpha=false)
 ctor for 3D texture with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, SLint depth, const SLstring &imageFilename, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT, const SLstring &name="3D-Texture", SLbool loadGrayscaleIntoAlpha=false)
 ctor for 3D texture from a single file with depth as 3rd dimension More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLstring &imageFilenameXPos, const SLstring &imageFilenameXNeg, const SLstring &imageFilenameYPos, const SLstring &imageFilenameYNeg, const SLstring &imageFilenameZPos, const SLstring &imageFilenameZNeg, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown)
 ctor for cube mapping with internal image allocation More...
 
 ~SLGLTexture () override
 
virtual void build (SLint texUnit)
 
void deleteData ()
 Delete all data (CVImages and GPU textures) More...
 
void deleteDataGpu ()
 Deletes the OpenGL texture objects and releases the memory on the GPU. More...
 
void deleteImages ()
 Deletes the CVImages in _images. No more texture mapping in ray tracing. More...
 
void bindActive (SLuint texUnit=0)
 
void fullUpdate ()
 
void drawSprite (SLbool doUpdate, SLfloat x, SLfloat y, SLfloat w, SLfloat h)
 Draws the texture as 2D sprite with OpenGL buffers. More...
 
void cubeUV2XYZ (SLint index, SLfloat u, SLfloat v, SLfloat &x, SLfloat &y, SLfloat &z)
 Computes the unnormalised vector x,y,z from tex. coords. uv with cubemap index. More...
 
void cubeXYZ2UV (SLfloat x, SLfloat y, SLfloat z, SLint &index, SLfloat &u, SLfloat &v)
 Computes the uv and cubemap image index from a unnormalised vector x,y,z. More...
 
SLstring filterString (SLint glFilter)
 Returns OpenGL texture filter as string. More...
 
void texType (SLTextureType bt)
 
void uvIndex (SLbyte i)
 
void bumpScale (SLfloat bs)
 
void minFiler (SLint minF)
 
void magFiler (SLint magF)
 
void needsUpdate (SLbool update)
 
void textureSize (int width, int height)
 
void deleteImageAfterBuild (SLbool delImg)
 If deleteImageAfterBuild is set to true you won't be able to ray trace the scene. More...
 
SLuint width ()
 
SLuint height ()
 
SLuint depth ()
 
SLbyte uvIndex ()
 
SLint bytesPerPixel ()
 
SLint bytesOnGPU ()
 
SLint bytesInFile ()
 
CVVImage & images ()
 
SLenum target () const
 
SLuint texID () const
 
SLTextureType texType ()
 
SLfloat bumpScale () const
 
SLCol4f getTexelf (SLfloat u, SLfloat v, SLuint imgIndex=0)
 SLGLTexture::getTexelf returns a pixel color from u & v texture coordinates. More...
 
SLCol4f getTexelf (const SLVec3f &cubemapDir)
 SLGLTexture::getTexelf returns a pixel color at the specified cubemap direction. More...
 
SLbool hasAlpha ()
 
SLMat4f tm ()
 
SLbool autoCalcTM3D () const
 
SLbool needsUpdate ()
 
SLstring typeName ()
 Returns the texture type as string. More...
 
SLstring typeShortName ()
 Returns the texture type short. More...
 
bool isTexture ()
 
SLstring minificationFilterName ()
 
SLstring magnificationFilterName ()
 
void build2DMipmaps (SLint target, SLuint index)
 
SLbool copyVideoImage (SLint camWidth, SLint camHeight, CVPixelFormatGL glFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
 Copies the image data from a video camera into the current video image. More...
 
SLbool copyVideoImage (SLint camWidth, SLint camHeight, CVPixelFormatGL srcFormat, CVPixelFormatGL dstFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
 
void calc3DGradients (SLint sampleRadius, const function< void(int)> &onUpdateProgress)
 
void smooth3DGradients (SLint smoothRadius, function< void(int)> onUpdateProgress)
 
SLVec2f dudv (SLfloat u, SLfloat v)
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Static Public Member Functions

static SLTextureType detectType (const SLstring &filename)
 Detects the texture type from the filename appendix (See SLTexType def.) More...
 
static string internalFormatStr (int internalFormat)
 Returns the internal pixel format from OpenGL. More...
 

Static Public Attributes

static SLfloat maxAnisotropy = -1.0f
 Returns the derivation as [s,t]. More...
 
static SLuint totalNumBytesOnGPU = 0
 Total NO. of bytes used for textures on GPU. More...
 

Protected Member Functions

void load (const SLstring &filename, SLbool flipVertical=true, SLbool loadGrayscaleIntoAlpha=false)
 Loads the texture, converts color depth & applies vertical mirroring. More...
 
void load (const SLVCol4f &colors)
 Loads the 1D color data into an image of height 1. More...
 

Protected Attributes

CVVImage _images
 Vector of CVImage pointers. More...
 
SLuint _texID
 OpenGL texture ID. More...
 
SLTextureType _texType
 See SLTextureType. More...
 
SLint _width
 Texture image width in pixels (images exist either in _images or on the GPU or on both) More...
 
SLint _height
 Texture image height in pixels (images exist either in _images or on the GPU or on both) More...
 
SLint _depth
 3D Texture image depth (images exist either in _images or on the GPU or on both) More...
 
SLbyte _uvIndex
 Texture coordinate index in SLMesh (0 = default) More...
 
SLint _internalFormat
 Internal OpenGL format. More...
 
SLint _bytesPerPixel
 Bytes per texture image pixel (images exist either in _images or on the GPU or on both) More...
 
SLint _min_filter
 Minification filter. More...
 
SLint _mag_filter
 Magnification filter. More...
 
SLint _wrap_s
 Wrapping in s direction. More...
 
SLint _wrap_t
 Wrapping in t direction. More...
 
SLenum _target
 texture target More...
 
SLMat4f _tm
 texture matrix More...
 
SLuint _bytesOnGPU
 NO. of bytes on GPU. More...
 
SLuint _bytesInFile
 NO. of bytes in file. More...
 
SLbool _autoCalcTM3D
 Flag if texture matrix should be calculated from AABB for 3D mapping. More...
 
SLfloat _bumpScale
 Bump mapping scale factor. More...
 
SLbool _resizeToPow2
 Flag if image should be resized to n^2. More...
 
SLGLVertexArray _vaoSprite
 Vertex array object for sprite rendering. More...
 
std::atomic< bool > _needsUpdate {}
 Flag if image needs an single update. More...
 
std::mutex _mutex
 Mutex to protect parallel access (used in ray tracing) More...
 
SLbool _deleteImageAfterBuild
 Flag if images should be deleted after build on GPU. More...
 
SLbool _compressedTexture = false
 True for compressed texture format on GPU. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Texture object for OpenGL texturing.

The SLGLTexture class implements an OpenGL texture object that can be used by the SLMaterial class. A texture can have 1-n CVImages in the vector _images. A simple 2D texture has just a single texture image (_images[0]). For cube maps you will need 6 images (_images[0-5]). For 3D textures you can have as much images of the same size than your GPU and/or CPU memory can hold. The images are not released after the OpenGL texture creation unless you set the flag _deleteImageAfterBuild to true. If the images get deleted after build, you won't be able to ray trace the scene.

Constructor & Destructor Documentation

◆ SLGLTexture() [1/8]

SLGLTexture::SLGLTexture ( )

Default ctor for all stack instances (not created with new)

Default ctor for all stack instances such as the video textures in SLScene or the textures inherited by SLRaytracer. All other constructors add the this pointer to the SLScene::_texture vector for global deallocation.

◆ SLGLTexture() [2/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
const SLVCol4f colors,
SLint  min_filter = GL_LINEAR,
SLint  mag_filter = GL_LINEAR,
SLint  wrapS = GL_REPEAT,
const SLstring name = "2D-Texture" 
)
explicit

ctor for 1D texture with internal image allocation

Constructor for 1D texture from a color vector. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
colorsVector of colors
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
wrapSTexture wrapping in S direction (OpenGL constant)
nameName of the 1D texture

◆ SLGLTexture() [3/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
SLint  min_filter,
SLint  mag_filter,
SLint  wrapS,
SLint  wrapT,
SLenum  target = GL_TEXTURE_2D 
)
explicit

ctor for empty 2D textures

Constructor for empty 2D textures. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
wrapSTexture wrapping in S direction (OpenGL constant)
wrapTTexture wrapping in T direction (OpenGL constant)
targetTexture target GL_TEXTURE_1D, 2D, 3D

◆ SLGLTexture() [4/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
unsigned char *  data,
int  width,
int  height,
int  cvtype,
SLint  min_filter,
SLint  mag_filter,
SLTextureType  type,
SLint  wrapS,
SLint  wrapT 
)
explicit

ctor for 2D textures from byte pointer

Constructor for 2D texture with a passed image data pointer. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
dataData pointer to the first top-left pixel
widthWidth of the image in pixels
heightHeight of the image in pixels
cvtypeOpenCV image type
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
typeType of the texture
wrapSTexture wrapping in S direction (OpenGL constant)
wrapTTexture wrapping in T direction (OpenGL constant)

◆ SLGLTexture() [5/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
const SLstring filename,
SLint  min_filter = GL_LINEAR_MIPMAP_LINEAR,
SLint  mag_filter = GL_LINEAR,
SLTextureType  type = TT_unknown,
SLint  wrapS = GL_REPEAT,
SLint  wrapT = GL_REPEAT 
)
explicit

ctor for 2D textures with internal image allocation

Constructor for 2D textures from image file with internal image allocation. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
filenameName of the texture image file. If only a filename is passed it will be search on the SLGLTexture::defaultPath.
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
typeType of the texture
wrapSTexture wrapping in S direction (OpenGL constant)
wrapTTexture wrapping in T direction (OpenGL constant)

◆ SLGLTexture() [6/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
const SLVstring files,
SLint  min_filter = GL_LINEAR,
SLint  mag_filter = GL_LINEAR,
SLint  wrapS = GL_REPEAT,
SLint  wrapT = GL_REPEAT,
const SLstring name = "3D-Texture",
SLbool  loadGrayscaleIntoAlpha = false 
)
explicit

ctor for 3D texture with internal image allocation

Constructor for 3D textures from image files with internal image allocation. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
filesVector of texture image files. If only filenames are passed they will be searched on the SLGLTexture::defaultPath.
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
wrapSTexture wrapping in S direction (OpenGL constant)
wrapTTexture wrapping in T direction (OpenGL constant)
nameName of the 3D texture
loadGrayscaleIntoAlphaFlag if grayscale image should be loaded into alpha channel.

◆ SLGLTexture() [7/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
SLint  depth,
const SLstring filename,
SLint  min_filter = GL_LINEAR,
SLint  mag_filter = GL_LINEAR,
SLint  wrapS = GL_REPEAT,
SLint  wrapT = GL_REPEAT,
const SLstring name = "3D-Texture",
SLbool  loadGrayscaleIntoAlpha = false 
)
explicit

ctor for 3D texture from a single file with depth as 3rd dimension

Constructor for 3D textures from single image file that is stacked depth times. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
depthDepth of 3D texture.
filenametexture image file. If only filenames are passed they will be searched on the SLGLTexture::defaultPath.
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
wrapSTexture wrapping in S direction (OpenGL constant)
wrapTTexture wrapping in T direction (OpenGL constant)
nameName of the 3D texture
loadGrayscaleIntoAlphaFlag if grayscale image should be loaded into alpha channel.

◆ SLGLTexture() [8/8]

SLGLTexture::SLGLTexture ( SLAssetManager assetMgr,
const SLstring filenameXPos,
const SLstring filenameXNeg,
const SLstring filenameYPos,
const SLstring filenameYNeg,
const SLstring filenameZPos,
const SLstring filenameZNeg,
SLint  min_filter = GL_LINEAR,
SLint  mag_filter = GL_LINEAR,
SLTextureType  type = TT_unknown 
)

ctor for cube mapping with internal image allocation

Constructor for a cubemap texture from 6 image files. Textures can be used in multiple materials. Textures can belong therefore to the global assets such as meshes (SLMesh), materials (SLMaterial), textures (SLGLTexture) and shader programs (SLGLProgram).

Parameters
assetMgrPointer to a global asset manager. If passed the asset manager is the owner of the instance and will do the deallocation. If a nullptr is passed the creator is responsible for the deallocation.
filenameXPosFilename of the cubemap image in the pos. X direction.
filenameXNegFilename of the cubemap image in the neg. X direction.
filenameYPosFilename of the cubemap image in the pos. Y direction.
filenameYNegFilename of the cubemap image in the neg. Y direction.
filenameZPosFilename of the cubemap image in the pos. Z direction.
filenameZNegFilename of the cubemap image in the neg. Z direction.
min_filterMinification filter constant from OpenGL
mag_filterMagnification filter constant from OpenGL
typeTexture Type

◆ ~SLGLTexture()

SLGLTexture::~SLGLTexture ( )
override

The destructor should be called by the owner of the texture. If an asset manager was passed in the constructor it will do it after scene destruction. The destructor deletes all images in the RAM as well as the texture objects on the GPU.

Member Function Documentation

◆ autoCalcTM3D()

SLbool SLGLTexture::autoCalcTM3D ( ) const
inline

◆ bindActive()

void SLGLTexture::bindActive ( SLuint  texUnit = 0)

SLGLTexture::bindActive binds the active texture. This method must be called by the object that uses the texture every time BEFORE the its rendering. The texUnit is only used for multi texturing. Before the first time the texture is passed to OpenGL.

◆ build()

void SLGLTexture::build ( SLint  texUnit)
virtual

Builds an OpenGL texture object with the according OpenGL commands. This texture creation must be done only once when a valid OpenGL rendering context is present. This function is called the first time within the enable method which is called by object that uses the texture.

Reimplemented in SLGLTextureIBL.

◆ build2DMipmaps()

void SLGLTexture::build2DMipmaps ( SLint  target,
SLuint  index 
)

◆ bumpScale() [1/2]

SLfloat SLGLTexture::bumpScale ( ) const
inline

◆ bumpScale() [2/2]

void SLGLTexture::bumpScale ( SLfloat  bs)
inline

◆ bytesInFile()

SLint SLGLTexture::bytesInFile ( )
inline

◆ bytesOnGPU()

SLint SLGLTexture::bytesOnGPU ( )
inline

◆ bytesPerPixel()

SLint SLGLTexture::bytesPerPixel ( )
inline

◆ calc3DGradients()

void SLGLTexture::calc3DGradients ( SLint  sampleRadius,
const function< void(int)> &  onUpdateProgress 
)

SLGLTexture::calc3DGradients calculates the normals based on the 3D gradient of all images and stores them in the RGB components.

Parameters
sampleRadiusDistance from center to calculate the gradient
onUpdateProgressCallback function for progress display

◆ copyVideoImage() [1/2]

SLbool SLGLTexture::copyVideoImage ( SLint  camWidth,
SLint  camHeight,
CVPixelFormatGL  srcFormat,
SLuchar data,
SLbool  isContinuous,
SLbool  isTopLeft 
)

Copies the image data from a video camera into the current video image.

SLGLTexture::copyVideoImage

Parameters
camWidthWidth in pixels of the camera image
camHeightHeight in pixels of the camera image
srcFormatPixel format according to the OpenGL pixel formats
dataPointer to the first byte of the first pixel
isContinuousFlag if the next line comes after the last byte of the prev. line
isTopLeftFlag if the data pointer points to the top left pixel
Returns
Returns true if the texture was rebuilt It is important that passed pixel format is either PF_LUMINANCE, RGB or RGBA. otherwise an expensive conversion must be done.

◆ copyVideoImage() [2/2]

SLbool SLGLTexture::copyVideoImage ( SLint  camWidth,
SLint  camHeight,
CVPixelFormatGL  srcFormat,
CVPixelFormatGL  dstFormat,
SLuchar data,
SLbool  isContinuous,
SLbool  isTopLeft 
)

◆ cubeUV2XYZ()

void SLGLTexture::cubeUV2XYZ ( SLint  index,
SLfloat  u,
SLfloat  v,
SLfloat x,
SLfloat y,
SLfloat z 
)

Computes the unnormalised vector x,y,z from tex. coords. uv with cubemap index.

A cube texture indexes six texture maps from 0 to 5 in order Positive X, Negative X, Positive Y, Negative Y, Positive Z, Negative Z. The images are stored with the origin at the lower left of the image. The Positive X and Y faces must reverse the Z coordinate and the Negative Z face must negate the X coordinate. If given the face, and texture coordinates (u,v), the unnormalized vector (x,y,z) are computed. Source:
https://en.wikipedia.org/wiki/Cube_mapping

◆ cubeXYZ2UV()

void SLGLTexture::cubeXYZ2UV ( SLfloat  x,
SLfloat  y,
SLfloat  z,
SLint index,
SLfloat u,
SLfloat v 
)

Computes the uv and cubemap image index from a unnormalised vector x,y,z.

See also SLGLTexture::cubeUV2XYZ. Source:
https://en.wikipedia.org/wiki/Cube_mapping

◆ deleteData()

void SLGLTexture::deleteData ( )

Delete all data (CVImages and GPU textures)

◆ deleteDataGpu()

void SLGLTexture::deleteDataGpu ( )

Deletes the OpenGL texture objects and releases the memory on the GPU.

◆ deleteImageAfterBuild()

void SLGLTexture::deleteImageAfterBuild ( SLbool  delImg)
inline

If deleteImageAfterBuild is set to true you won't be able to ray trace the scene.

◆ deleteImages()

void SLGLTexture::deleteImages ( )

Deletes the CVImages in _images. No more texture mapping in ray tracing.

◆ depth()

SLuint SLGLTexture::depth ( )
inline

◆ detectType()

SLTextureType SLGLTexture::detectType ( const SLstring filename)
static

Detects the texture type from the filename appendix (See SLTexType def.)

◆ drawSprite()

void SLGLTexture::drawSprite ( SLbool  doUpdate,
SLfloat  x,
SLfloat  y,
SLfloat  w,
SLfloat  h 
)

Draws the texture as 2D sprite with OpenGL buffers.

Draws the texture as a flat 2D sprite with a height and a width on two triangles with zero in the bottom left corner:
w +--—+ | /| | / | h | / | | / | |/ | 0 +--—+ 0

◆ dudv()

SLVec2f SLGLTexture::dudv ( SLfloat  u,
SLfloat  v 
)

dudv calculates the partial derivation (gray value slope) at u,v for bump mapping either from a height map or a normal map

◆ filterString()

SLstring SLGLTexture::filterString ( SLint  glFilter)

Returns OpenGL texture filter as string.

◆ fullUpdate()

void SLGLTexture::fullUpdate ( )

Fully updates the OpenGL internal texture data by the image data

◆ getTexelf() [1/2]

SLCol4f SLGLTexture::getTexelf ( const SLVec3f cubemapDir)

SLGLTexture::getTexelf returns a pixel color at the specified cubemap direction.

◆ getTexelf() [2/2]

SLCol4f SLGLTexture::getTexelf ( SLfloat  u,
SLfloat  v,
SLuint  imgIndex = 0 
)

SLGLTexture::getTexelf returns a pixel color from u & v texture coordinates.

If the OpenGL filtering is set to GL_LINEAR a bilinear interpolated color out of four neighboring pixels is return. Otherwise the nearest pixel is returned.

◆ hasAlpha()

SLbool SLGLTexture::hasAlpha ( )
inline

◆ height()

SLuint SLGLTexture::height ( )
inline

◆ images()

CVVImage & SLGLTexture::images ( )
inline

◆ internalFormatStr()

string SLGLTexture::internalFormatStr ( int  internalFormat)
static

Returns the internal pixel format from OpenGL.

Taken from https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml

◆ isTexture()

bool SLGLTexture::isTexture ( )
inline

◆ load() [1/2]

void SLGLTexture::load ( const SLstring filename,
SLbool  flipVertical = true,
SLbool  loadGrayscaleIntoAlpha = false 
)
protected

Loads the texture, converts color depth & applies vertical mirroring.

◆ load() [2/2]

void SLGLTexture::load ( const SLVCol4f colors)
protected

Loads the 1D color data into an image of height 1.

◆ magFiler()

void SLGLTexture::magFiler ( SLint  magF)
inline

◆ magnificationFilterName()

SLstring SLGLTexture::magnificationFilterName ( )
inline

◆ minFiler()

void SLGLTexture::minFiler ( SLint  minF)
inline

◆ minificationFilterName()

SLstring SLGLTexture::minificationFilterName ( )
inline

◆ needsUpdate() [1/2]

SLbool SLGLTexture::needsUpdate ( )
inline

◆ needsUpdate() [2/2]

void SLGLTexture::needsUpdate ( SLbool  update)
inline

◆ smooth3DGradients()

void SLGLTexture::smooth3DGradients ( SLint  smoothRadius,
function< void(int)>  onUpdateProgress 
)

SLGLTexture::smooth3DGradients smooths the 3D gradients in the RGB channels of all images.

Parameters
smoothRadiusSoothing radius
onUpdateProgressCallback function for progress display

◆ target()

SLenum SLGLTexture::target ( ) const
inline

◆ texID()

SLuint SLGLTexture::texID ( ) const
inline

◆ textureSize()

void SLGLTexture::textureSize ( int  width,
int  height 
)
inline

◆ texType() [1/2]

SLTextureType SLGLTexture::texType ( )
inline

◆ texType() [2/2]

void SLGLTexture::texType ( SLTextureType  bt)
inline

◆ tm()

SLMat4f SLGLTexture::tm ( )
inline

◆ typeName()

SLstring SLGLTexture::typeName ( )

Returns the texture type as string.

◆ typeShortName()

SLstring SLGLTexture::typeShortName ( )

Returns the texture type short.

◆ uvIndex() [1/2]

SLbyte SLGLTexture::uvIndex ( )
inline

◆ uvIndex() [2/2]

void SLGLTexture::uvIndex ( SLbyte  i)
inline

◆ width()

SLuint SLGLTexture::width ( )
inline

Member Data Documentation

◆ _autoCalcTM3D

SLbool SLGLTexture::_autoCalcTM3D
protected

Flag if texture matrix should be calculated from AABB for 3D mapping.

◆ _bumpScale

SLfloat SLGLTexture::_bumpScale
protected

Bump mapping scale factor.

◆ _bytesInFile

SLuint SLGLTexture::_bytesInFile
protected

NO. of bytes in file.

◆ _bytesOnGPU

SLuint SLGLTexture::_bytesOnGPU
protected

NO. of bytes on GPU.

◆ _bytesPerPixel

SLint SLGLTexture::_bytesPerPixel
protected

Bytes per texture image pixel (images exist either in _images or on the GPU or on both)

◆ _compressedTexture

SLbool SLGLTexture::_compressedTexture = false
protected

True for compressed texture format on GPU.

◆ _deleteImageAfterBuild

SLbool SLGLTexture::_deleteImageAfterBuild
protected

Flag if images should be deleted after build on GPU.

◆ _depth

SLint SLGLTexture::_depth
protected

3D Texture image depth (images exist either in _images or on the GPU or on both)

◆ _height

SLint SLGLTexture::_height
protected

Texture image height in pixels (images exist either in _images or on the GPU or on both)

◆ _images

CVVImage SLGLTexture::_images
protected

Vector of CVImage pointers.

◆ _internalFormat

SLint SLGLTexture::_internalFormat
protected

Internal OpenGL format.

◆ _mag_filter

SLint SLGLTexture::_mag_filter
protected

Magnification filter.

◆ _min_filter

SLint SLGLTexture::_min_filter
protected

Minification filter.

◆ _mutex

std::mutex SLGLTexture::_mutex
protected

Mutex to protect parallel access (used in ray tracing)

◆ _needsUpdate

std::atomic<bool> SLGLTexture::_needsUpdate {}
protected

Flag if image needs an single update.

◆ _resizeToPow2

SLbool SLGLTexture::_resizeToPow2
protected

Flag if image should be resized to n^2.

◆ _target

SLenum SLGLTexture::_target
protected

texture target

◆ _texID

SLuint SLGLTexture::_texID
protected

OpenGL texture ID.

◆ _texType

SLTextureType SLGLTexture::_texType
protected

See SLTextureType.

◆ _tm

SLMat4f SLGLTexture::_tm
protected

texture matrix

◆ _uvIndex

SLbyte SLGLTexture::_uvIndex
protected

Texture coordinate index in SLMesh (0 = default)

◆ _vaoSprite

SLGLVertexArray SLGLTexture::_vaoSprite
protected

Vertex array object for sprite rendering.

◆ _width

SLint SLGLTexture::_width
protected

Texture image width in pixels (images exist either in _images or on the GPU or on both)

◆ _wrap_s

SLint SLGLTexture::_wrap_s
protected

Wrapping in s direction.

◆ _wrap_t

SLint SLGLTexture::_wrap_t
protected

Wrapping in t direction.

◆ maxAnisotropy

SLfloat SLGLTexture::maxAnisotropy = -1.0f
static

Returns the derivation as [s,t].

maxAnisotropy=-1 show that GL_EXT_texture_filter_anisotropic is not checked

max. anisotropy available

◆ totalNumBytesOnGPU

SLuint SLGLTexture::totalNumBytesOnGPU = 0
static

Total NO. of bytes used for textures on GPU.

NO. of texture byte allocated on GPU.


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