Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
G3D::Texture Class Reference


A 1D, 2D, or 3D array (e.g., an image) stored on the GPU, commonly used for mapping reflectance values (colors) over meshes. More...

Inherits G3D::ReferenceCountedObject.

Classes

class  Encoding
 
Attaches semantics for reading and writing this texture beyond the OpenGL bitwise description. More...
 
class  LoadingInfo
 All transient information used by image loading and preprocessing of Textures, collected here so that the process can efficiently run on separate threads in a multithreaded environment. More...
 
class  Preprocess
 
class  Specification
 
class  TexelType
 
class  Visualization
 

Public Types

enum  Dimension {
  DIM_2D = GL_TEXTURE_2D,
  DIM_2D_ARRAY = GL_TEXTURE_2D_ARRAY,
  DIM_3D = GL_TEXTURE_3D,
  DIM_2D_RECT = GL_TEXTURE_RECTANGLE,
  DIM_CUBE_MAP = GL_TEXTURE_CUBE_MAP,
  DIM_CUBE_MAP_ARRAY = GL_TEXTURE_CUBE_MAP_ARRAY
}
 These values are guaranteed to correspond to the equivalent OpenGL constant, so they can be cast directly for convenience when porting. More...
 

Public Member Functions

virtual ~Texture ()
 
Deallocates the OpenGL texture. More...
 
AlphaFilter alphaFilter () const
 The value that AlphaFilter::DETECT should use for this texture when applied to a G3D::UniversalMaterial. More...
 
shared_ptr< TexturealphaOnlyVersion () const
 Creates another texture that is the same as this one but contains only an alpha channel. More...
 
bool appearsInTextureBrowserWindow () const
 
String caption () const
 Suggested caption for screen capture. More...
 
void clear (int mipLevel=0)
 Clear the texture to 0's (typically after creation, so that it does not contain unitialized data). More...
 
bool conservativelyHasNonUnitAlpha () const
 Returns true if this texture might have non-unit alpha without forcing lazy loading to complete. More...
 
bool conservativelyHasUnitAlpha () const
 Returns true if this texture cannot have non-unit alpha, without forcing lazy loading to complete. More...
 
void copyFromScreen (const Rect2D &rect, const ImageFormat *fmt=nullptr)
 
Copies data from screen into an existing texture (replacing whatever was previously there). More...
 
void copyFromScreen (const Rect2D &rect, CubeFace face)
 
Copies into the specified face of a cube map. More...
 
bool copyInto (shared_ptr< Texture > &dest, CubeFace cf=CubeFace::POS_X, int mipLevel=0, RenderDevice *rd=nullptr) const
 
Copies this texture over dest, allocating or resizing dest as needed. More...
 
int depth () const
 
Dimension dimension () const
 
const Encodingencoding () const
 
const ImageFormatformat () const
 
void generateMipMaps ()
 For a texture with that supports the FrameBufferObject extension, generate mipmaps from the level 0 mipmap immediately. More...
 
void getTexImage (void *data, const ImageFormat *desiredFormat, CubeFace face=CubeFace::POS_X, int mipLevel=0) const
 
bool hasMipMaps () const
 
int height () const
 Number of horizontal texels in the level 0 mipmap. More...
 
bool isCubeMap () const
 Deprecated, use dimension() == Texture::DIM_CUBE_MAP instead. More...
 
Color4 max () const
 If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), then this is the largest value in the texture, modified by the encoding's scale and bias. More...
 
Color4 mean () const
 If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), then this is the average value in the texture, modified by the encoding's scale and bias. More...
 
Color4 min () const
 If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), this is the smallest value in the texture, modified by the encoding's scale and bias. More...
 
const Stringname () const
 For debugging purposes, appears in the texture viewer. More...
 
int numMipMapLevels ()
 
int numSamples ()
 
bool opaque () const
 
True if this texture was created with an alpha channel. More...
 
unsigned int openGLID () const
 
unsigned int openGLTextureTarget () const
 
The OpenGL texture target this binds (e.g. More...
 
Color4 readTexel (int ix, int iy, class RenderDevice *rd=nullptr, int mipLevel=0, int iz=0, CubeFace face=CubeFace::POS_X) const
 Reads back a single texel. More...
 
Rect2D rect2DBounds () const
 Returns a rectangle whose m_width and m_height match the dimensions of the texture. More...
 
void registerReallocationHook (std::function< void(GLuint)> reallocateHook) const
 
void resize (int w, int h)
 Resize the underlying OpenGL texture memory buffer, without reallocating the OpenGL texture ID. More...
 
void resize (int w, int h, int d)
 New resize for 3D textures. More...
 
void setCaption (const String &c)
 
void setName (const String &n)
 
void setShaderArgs (class UniformTable &args, const String &prefix, const Sampler &sampler)
 Binds the following uniforms: More...
 
int sizeInMemory () const
 
How much (texture) memory this texture occupies. More...
 
TexelType texelType () const
 
shared_ptr< class CubeMaptoCubeMap () const
 
shared_ptr< Image1unorm8toDepthImage1unorm8 () const
 Extracts the data as ImageFormat::DEPTH32F and converts to 8-bit. More...
 
shared_ptr< Map2D< float > > toDepthMap () const
 Extracts the data as ImageFormat::DEPTH32F. More...
 
shared_ptr< ImagetoImage (const ImageFormat *outFormat=ImageFormat::AUTO(), int mipLevel=0, CubeFace face=CubeFace::POS_X) const
 
shared_ptr< GLPixelTransferBuffertoPixelTransferBuffer (const ImageFormat *outFormat=ImageFormat::AUTO(), int mipLevel=0, CubeFace face=CubeFace::POS_X) const
 
void toPixelTransferBuffer (shared_ptr< GLPixelTransferBuffer > &buffer, const ImageFormat *outFormat=ImageFormat::AUTO(), int mipLevel=0, CubeFace face=CubeFace::POS_X, bool runMapHooks=true) const
 
void update (const shared_ptr< PixelTransferBuffer > &src, int mipLevel=0, CubeFace face=CubeFace::POS_X, bool runMapHooks=true, size_t byteOffset=0, bool resizeTexture=true)
 Upload new data from the CPU to this texture. More...
 
Vector2 vector2Bounds () const
 
int width () const
 Number of horizontal texels in the level 0 mipmap. More...
 

Static Public Member Functions

static void clearCache ()
 Textures are normally cached by Texture::Specification to speed loading and reduce memory consumption unless explicitly flagged not to enter the cache. More...
 
static void copy (shared_ptr< Texture > src, shared_ptr< Texture > dst, int srcMipLevel=0, int dstMipLevel=0, float scale=1.0f, const Vector2int16 &shift=Vector2int16(0, 0), CubeFace srcCubeFace=CubeFace::POS_X, CubeFace dstCubeFace=CubeFace::POS_X, RenderDevice *rd=nullptr, bool resize=true, int srcLayer=0, int dstLayer=0)
 
Copies src to dst, resizing if resize == true (the default). More...
 
static shared_ptr< TexturecosHemiRandom ()
 Returns a texture of 1024^2 oct32-encoded cosine-weighted hemispherical random vectors about the positive z-axis. More...
 
static shared_ptr< Texturecreate (const Specification &s)
 
static shared_ptr< TexturecreateColorCube (const Color4 &color)
 
static shared_ptr< TexturecreateEmpty (const String &name, int width, int height, const Encoding &encoding=Encoding(ImageFormat::RGBA8()), Dimension dimension=DIM_2D, bool generateMipMaps=false, int depth=1, int numSamples=1)
 
Creates an empty texture (useful for later reading from the screen). More...
 
static const CubeMapConvention::CubeMapInfocubeMapInfo (CubeMapConvention convention)
 Returns the mapping from [0, 5] to cube map faces and filename suffixes. More...
 
static CubeMapConvention determineCubeConvention (const String &filename)
 filename should contain a * wildcard More...
 
static shared_ptr< TexturefromFile (const String &filenameSpec, const Encoding encoding=Encoding(), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults(), bool preferSRGBForAuto=false)
 
Creates a texture from a single image or a set of files for a texture array or cube map based on a wildcard specification such as foo-*.png. More...
 
static shared_ptr< TexturefromGLTexture (const String &name, GLuint textureID, Encoding encoding, AlphaFilter alphaFilter, Dimension dimension=DIM_2D, bool destroyGLTextureInDestructor=true, int numSamples=1, int width=-1, int height=-1, int depth=-1, bool hasMIPMaps=false)
 
Wrap will override the existing parameters on the GL texture. More...
 
static shared_ptr< TexturefromImage (const String &name, const shared_ptr< Image > &image, const ImageFormat *desiredFormat=ImageFormat::AUTO(), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults())
 Shorthand for Texture::fromPixelTransferBuffer(name, image->toPixelTransferBuffer(), ...) More...
 
static shared_ptr< TexturefromMemory (const String &name, const Array< Array< const void *> > &bytes, const ImageFormat *bytesFormat, int width, int height, int depth, int numSamples=1, Encoding encoding=Encoding(ImageFormat::AUTO()), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults(), bool preferSRGBForAuto=false)
 
Construct from an explicit set of (optional) mipmaps and (optional) cubemap faces. More...
 
static shared_ptr< TexturefromMemory (const String &name, const void *bytes, const ImageFormat *bytesFormat, int width, int height, int depth, int numSamples=1, Encoding encoding=Encoding(), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults(), bool preferSRGBForAuto=false)
 Construct from a single packed 2D or 3D data set. More...
 
static shared_ptr< TexturefromPixelTransferBuffer (const String &name, const shared_ptr< PixelTransferBuffer > &image, Encoding desiredEncoding=Encoding(), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults())
 
static shared_ptr< TexturefromTwoFiles (const String &filename, const String &alphaFilename, Encoding encoding=Encoding(), Dimension dimension=DIM_2D, bool generateMipMaps=true, const Preprocess &preprocess=Preprocess::defaults(), bool preferSRGBForAuto=true, const bool useAlpha=false)
 
Creates a texture from the colors of filename and takes the alpha values from the red channel of alpha filename if useAlpha is set to true, it will use the alpha channel instead. More...
 
static void getAllTextures (Array< shared_ptr< Texture >> &textures)
 
static void getAllTextures (Array< weak_ptr< Texture >> &textures)
 
static void getCubeMapRotation (CubeFace face, Matrix3 &outMatrix)
 
Returns the rotation matrix that should be used for rendering the given cube map face. More...
 
static shared_ptr< TexturegetTextureByName (const String &textureName)
 Returns a pointer to a texture with the name textureName, if such a texture exists. More...
 
static bool isSupportedImage (const String &filename)
 Returns true if the specified filename exists and is an image that can be loaded as a Texture. More...
 
static const shared_ptr< Texture > & one ()
 Returns a small all-white (1,1,1,1) texture.
More...
 
static const shared_ptr< Texture > & opaqueBlack (Dimension d=DIM_2D)
 Returns a small opaque all-black (0,0,0,1) texture. More...
 
static const shared_ptr< Texture > & opaqueBlackCube ()
 Returns a small opaque all-black (0,0,0,1) texture. More...
 
static const shared_ptr< Texture > & opaqueBlackIfNull (const shared_ptr< Texture > &t)
 Returns t if it is non-nullptr, or opaqueBlack() if t is nullptr. More...
 
static const shared_ptr< Texture > & opaqueGray ()
 Returns a small all-gray (0.5,0.5,0.5,1) texture. More...
 
static const shared_ptr< Texture > & opaqueGrayIfNull (const shared_ptr< Texture > &t)
 Returns t if it is non-nullptr, or gray() if t is nullptr. More...
 
static shared_ptr< TexturesingleChannelDifference (RenderDevice *rd, const shared_ptr< Texture > &t0, const shared_ptr< Texture > &t1, int channel=0)
 Returns an RG32F difference texture of the same dimensions as t0 and t1 of (t0 - t1) of the specified channel, with positive values in the red channel and negative values in the green. More...
 
static int64 sizeOfAllTexturesInMemory ()
 
Video memory occupied by all OpenGL textures allocated using Texture or maintained by pointers to a Texture. More...
 
static shared_ptr< TexturesphereRandom ()
 Returns a texture of 1024^2 oct32-encoded uniformly distributed random vectors on the sphere. More...
 
static void splitFilenameAtWildCard (const String &filename, String &filenameBeforeWildCard, String &filenameAfterWildCard)
 
Splits a filename around the '*' character– used by cube maps to generate all filenames. More...
 
static bool supportsWrapMode (WrapMode m)
 
Returns true if this is a legal wrap mode for a G3D::Texture. More...
 
static DepthReadMode toDepthReadMode (const String &s)
 
static Dimension toDimension (const String &s)
 
static const char * toString (DepthReadMode m)
 
static const char * toString (Dimension m)
 
static shared_ptr< TextureuniformRandom ()
 Returns a texture of 1024^2 RG16 vectors of uniformly distributed random numbers: ([0,1], [0,1]). More...
 
static const shared_ptr< Texture > & white ()
 Returns a small all-white (1,1,1,1) texture. More...
 
static const shared_ptr< Texture > & whiteCube ()
 Returns a small all-white (1,1,1,1) cube map texture. More...
 
static const shared_ptr< Texture > & whiteCubeIfNull (const shared_ptr< Texture > &t)
 Returns t if it is non-nullptr, or whiteCube() if t is nullptr. More...
 
static const shared_ptr< Texture > & whiteIfNull (const shared_ptr< Texture > &t)
 Returns t if it is non-nullptr, or white() if t is nullptr. More...
 
static const shared_ptr< Texture > & zero (Dimension d=DIM_2D)
 Returns a small, all zero Color4(0,0,0,0) texture. More...
 
static const shared_ptr< Texture > & zeroIfNull (const shared_ptr< Texture > &t)
 Returns t if it is non-nullptr, or zero() if t is nullptr. More...
 

Public Attributes

Visualization visualization
 Used to display this Texture in a GuiTextureBox. More...
 

Protected Types

typedef Array< Array< const void * > > MIPCubeFacePointerArray
 
typedef Array< Array< shared_ptr< PixelTransferBuffer > > > MIPCubeFacePTBArray
 

Protected Member Functions

 Texture (const String &name, int width, int height, int depth, Dimension dimension, const Encoding &encoding, int numSamples, bool needsForce)
 
void completeCPULoading ()
 Perform the next CPU steps specified in m_loadingInfo. More...
 
void completeGPULoading ()
 Perform the final GPU step specified in m_loadingInfo. More...
 
void force () const
 If the underlying texture has not yet been uploaded to the GPU, then this method immediately blocks on the loading thread and does not return until the upload is completed. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 
static unsigned int newGLTextureID ()
 
Helper method. More...
 

Protected Attributes

bool m_appearsInTextureBrowserWindow
 If true, this texture can be registered in the TextureBrowser for run-time debugging. More...
 
Sampler m_cachedSamplerSettings
 
String m_caption
 
bool m_conservativelyHasNonUnitAlpha = false
 
bool m_conservativelyHasUnitAlpha = false
 
int m_depth
 
bool m_destroyGLTextureInDestructor
 True if the GL texture is owned by the instance and should be cleaned up with the class instance. More...
 
AlphaFilter m_detectedHint
 What AlphaFilter::DETECT should resolve to for this texture. More...
 
Dimension m_dimension
 
Encoding m_encoding
 
bool m_hasMipMaps
 
int m_height
 
LoadingInfom_loadingInfo = nullptr
 
std::mutex m_loadingMutex
 Protects m_needsForce, m_loadingThread, and m_loadingGLCallback. More...
 
std::thread * m_loadingThread = nullptr
 The thread that lazy loads into memory by invoking the m_loadingCPUCallbackQueue callbacks. More...
 
Color4 m_max
 Invoke force() before accessing. More...
 
Color4 m_mean
 Invoke force() before accessing. More...
 
Color4 m_min
 Invoke force() before accessing. More...
 
String m_name
 
volatile bool m_needsForce = false
 If true, this Texture is waiting for loading and/or upload to the GPU. More...
 
int m_numSamples
 Multi-sampled texture parameters. More...
 
bool m_opaque
 
shared_ptr< std::function< void(GLuint)> > m_reallocateHook
 
GLuint m_textureID
 OpenGL texture ID. More...
 
int m_width
 

Static Protected Attributes

static int64 m_sizeOfAllTexturesInMemory
 
static WeakCache< uintptr_t, shared_ptr< Texture > > s_allTextures
 Used for the Texture browser. More...
 
static WeakCache< Specification, shared_ptr< Texture > > s_cache
 Used to avoid re-loading textures. More...
 

Friends

class BufferTexture
 
template<class C , class I >
class Component
 
class GLSamplerObject
 
template<class I >
class MapComponent
 
class Shader
 

Detailed Description


A 1D, 2D, or 3D array (e.g., an image) stored on the GPU, commonly used for mapping reflectance values (colors) over meshes.

Abstraction of OpenGL textures. This class can be used with raw OpenGL, without RenderDevice. G3D::Texture supports all of the image formats that G3D::Image can load, and DDS (DirectX textures), and Quake-style cube maps.

If you enable texture compression, textures will be compressed on the fly. This can be slow (up to a second).

The special filename "<white>" generates an all-white Color4 texture (this works for both 2D and cube map texures; "<whiteCube>" can also be used explicitly for cube maps). You can use Preprocess::modulate to create other colors from this.

Member Typedef Documentation

◆ MIPCubeFacePointerArray

typedef Array<Array<const void*> > G3D::Texture::MIPCubeFacePointerArray
protected

◆ MIPCubeFacePTBArray

Member Enumeration Documentation

◆ Dimension

These values are guaranteed to correspond to the equivalent OpenGL constant, so they can be cast directly for convenience when porting.

Enumerator
DIM_2D 
DIM_2D_ARRAY 
DIM_3D 
DIM_2D_RECT 
DIM_CUBE_MAP 
DIM_CUBE_MAP_ARRAY 

Constructor & Destructor Documentation

◆ Texture()

G3D::Texture::Texture ( const String name,
int  width,
int  height,
int  depth,
Dimension  dimension,
const Encoding encoding,
int  numSamples,
bool  needsForce 
)
protected

◆ ~Texture()

virtual G3D::Texture::~Texture ( )
virtual


Deallocates the OpenGL texture.

Member Function Documentation

◆ alphaFilter()

AlphaFilter G3D::Texture::alphaFilter ( ) const
inline

The value that AlphaFilter::DETECT should use for this texture when applied to a G3D::UniversalMaterial.

If this returns AlphaFilter::DETECT, then detection has not been executed, likely because the texture was not in an 8-bit format.

◆ alphaOnlyVersion()

shared_ptr<Texture> G3D::Texture::alphaOnlyVersion ( ) const

Creates another texture that is the same as this one but contains only an alpha channel.

Alpha-only textures are useful as mattes.
If the current texture is opaque(), returns nullptr (since it is not useful to construct an alpha-only version of a texture without an alpha channel).

Like all texture construction methods, this is fairly slow and should not be called every frame during interactive rendering.

◆ appearsInTextureBrowserWindow()

bool G3D::Texture::appearsInTextureBrowserWindow ( ) const
inline

◆ caption()

String G3D::Texture::caption ( ) const

Suggested caption for screen capture.

If empty, returns name().

See also
name, setName

◆ clear()

void G3D::Texture::clear ( int  mipLevel = 0)

Clear the texture to 0's (typically after creation, so that it does not contain unitialized data).

◆ clearCache()

static void G3D::Texture::clearCache ( )
static

Textures are normally cached by Texture::Specification to speed loading and reduce memory consumption unless explicitly flagged not to enter the cache.

This method flushes the G3D-wide Texture cache to allow it to reload from disk.

◆ completeCPULoading()

void G3D::Texture::completeCPULoading ( )
protected

Perform the next CPU steps specified in m_loadingInfo.

Blocks. Does nothing if GPU loading is already complete.

◆ completeGPULoading()

void G3D::Texture::completeGPULoading ( )
protected

Perform the final GPU step specified in m_loadingInfo.

It assumes that CPU loading has been completed and that the caller is on the GL thread.

deletes m_loadingInfo.

◆ conservativelyHasNonUnitAlpha()

bool G3D::Texture::conservativelyHasNonUnitAlpha ( ) const
inline

Returns true if this texture might have non-unit alpha without forcing lazy loading to complete.

◆ conservativelyHasUnitAlpha()

bool G3D::Texture::conservativelyHasUnitAlpha ( ) const
inline

Returns true if this texture cannot have non-unit alpha, without forcing lazy loading to complete.

◆ copy()

static void G3D::Texture::copy ( shared_ptr< Texture src,
shared_ptr< Texture dst,
int  srcMipLevel = 0,
int  dstMipLevel = 0,
float  scale = 1.0f,
const Vector2int16 shift = Vector2int16(0, 0),
CubeFace  srcCubeFace = CubeFace::POS_X,
CubeFace  dstCubeFace = CubeFace::POS_X,
RenderDevice rd = nullptr,
bool  resize = true,
int  srcLayer = 0,
int  dstLayer = 0 
)
static


Copies src to dst, resizing if resize == true (the default).

Both src and dst image formats are preserved.

At least one of the following must hold: either dstMipLevel == 0, or srcMipLevel == dstMipLevel.

Uses a shader and makes a draw call in some cases, and executes a direct copy in others.

Parameters
scaleSource coordinates are multipled by this before shift is added

API subject to change

Parameters
shiftAdd This to destination coordinates to find source coordinates. For example, use the negative guard band thickness to crop a guard band.

◆ copyFromScreen() [1/2]

void G3D::Texture::copyFromScreen ( const Rect2D rect,
const ImageFormat fmt = nullptr 
)


Copies data from screen into an existing texture (replacing whatever was previously there).

The dimensions must be powers of two or a texture rectangle will be created (not supported on some cards).

This call is provided for backwards compatibility on old cards. It is substantially slower than simply rendering to a G3D::Texture using a G3D::Framebuffer.

The (x, y) coordinates are in OpenGL coordinates. If a FrameBuffer is bound then (0, 0) is the top left of the screen. When rendering directly to a window, (0,0) is the lower left. Use RenderDevice::copyTextureFromScreen to obtain consistent coordinates.

The texture dimensions will be updated but all other properties will be preserved: The previous wrap mode will be preserved. The interpolation mode will be preserved (unless it required a mipmap, in which case it will be set to BILINEAR_NO_MIPMAP). The previous color m_depth and alpha m_depth will be preserved. Texture compression is not supported for textures copied from the screen.

To copy a depth texture, first create an empty depth texture then copy into it.

If you invoke this method on a texture that is currently set on RenderDevice, the texture will immediately be updated (there is no need to rebind).

Parameters
rectThe rectangle to copy (relative to the viewport)
fmtIf nullptr, uses the existing texture format, otherwise forces this texture to use the specified format.
See also
RenderDevice::screenShotPic
RenderDevice::setReadBuffer
Deprecated:

◆ copyFromScreen() [2/2]

void G3D::Texture::copyFromScreen ( const Rect2D rect,
CubeFace  face 
)


Copies into the specified face of a cube map.

Because cube maps can't have the Y direction inverted (and still do anything useful), you should render the cube map faces upside-down before copying them into the map. This is an unfortunate side-effect of OpenGL's cube map convention.
Use G3D::Texture::getCubeMapRotation to generate the (upside-down) camera orientations.

◆ copyInto()

bool G3D::Texture::copyInto ( shared_ptr< Texture > &  dest,
CubeFace  cf = CubeFace::POS_X,
int  mipLevel = 0,
RenderDevice rd = nullptr 
) const


Copies this texture over dest, allocating or resizing dest as needed.

(It reallocs if the internal formats mismatch or dest is null) Uses a shader and makes a draw call. If src is a depth texture, mipLevel must be 0.

DEPRECATED: To be replaced with a clearer API before G3D10 final release.

Returns
true if dest was allocated/reallocated

◆ cosHemiRandom()

static shared_ptr<Texture> G3D::Texture::cosHemiRandom ( )
static

Returns a texture of 1024^2 oct32-encoded cosine-weighted hemispherical random vectors about the positive z-axis.

Use octDecode(texelFetch(g3d_cosHemiRandom, pos, 0).xy) in a shader to decode these. This is automatically bound as g3d_cosHemiRandom in shaders that use it.

◆ create()

static shared_ptr<Texture> G3D::Texture::create ( const Specification s)
static

◆ createColorCube()

static shared_ptr<Texture> G3D::Texture::createColorCube ( const Color4 color)
static

◆ createEmpty()

static shared_ptr<Texture> G3D::Texture::createEmpty ( const String name,
int  width,
int  height,
const Encoding encoding = Encoding(ImageFormat::RGBA8()),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = false,
int  depth = 1,
int  numSamples = 1 
)
static


Creates an empty texture (useful for later reading from the screen).

See also
clear()

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ cubeMapInfo()

static const CubeMapConvention::CubeMapInfo& G3D::Texture::cubeMapInfo ( CubeMapConvention  convention)
static

Returns the mapping from [0, 5] to cube map faces and filename suffixes.

There are multiple filename conventions, so the suffixes specify each of the options.

◆ depth()

int G3D::Texture::depth ( ) const
inline

◆ determineCubeConvention()

static CubeMapConvention G3D::Texture::determineCubeConvention ( const String filename)
static

filename should contain a * wildcard

◆ dimension()

Dimension G3D::Texture::dimension ( ) const
inline

◆ encoding()

const Encoding& G3D::Texture::encoding ( ) const
inline

◆ force()

void G3D::Texture::force ( ) const
protected

If the underlying texture has not yet been uploaded to the GPU, then this method immediately blocks on the loading thread and does not return until the upload is completed.

Otherwise it does nothing. This should be called on the OpenGL thread.

See also
m_loadingThread, m_loadingGLCallback, m_loadingMutex, m_needsForce

Referenced by hasMipMaps(), max(), mean(), min(), opaque(), and openGLID().

◆ format()

const ImageFormat* G3D::Texture::format ( ) const
inline

◆ fromFile()

static shared_ptr<Texture> G3D::Texture::fromFile ( const String filenameSpec,
const Encoding  encoding = Encoding(),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults(),
bool  preferSRGBForAuto = false 
)
static


Creates a texture from a single image or a set of files for a texture array or cube map based on a wildcard specification such as foo-*.png.

Cube maps can have any common cube map specifier in the wildcard, such as "bk", "+z", or "pz". Texture arrays must have sequential integers in the wildcard. The image must have a format understood by G3D::Image or be a DirectDraw Surface (DDS).

◆ fromGLTexture()

static shared_ptr<Texture> G3D::Texture::fromGLTexture ( const String name,
GLuint  textureID,
Encoding  encoding,
AlphaFilter  alphaFilter,
Dimension  dimension = DIM_2D,
bool  destroyGLTextureInDestructor = true,
int  numSamples = 1,
int  width = -1,
int  height = -1,
int  depth = -1,
bool  hasMIPMaps = false 
)
static


Wrap will override the existing parameters on the GL texture.

Parameters
nameArbitrary name for this texture to identify it
textureIDSet to newGLTextureID() to create an empty texture.
destroyGLTextureInDestructorIf true, deallocate the OpenGL texture when the G3D::Texture is destroyed

◆ fromImage()

static shared_ptr<Texture> G3D::Texture::fromImage ( const String name,
const shared_ptr< Image > &  image,
const ImageFormat desiredFormat = ImageFormat::AUTO(),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults() 
)
static

◆ fromMemory() [1/2]

static shared_ptr<Texture> G3D::Texture::fromMemory ( const String name,
const Array< Array< const void *> > &  bytes,
const ImageFormat bytesFormat,
int  width,
int  height,
int  depth,
int  numSamples = 1,
Encoding  encoding = Encoding(ImageFormat::AUTO()),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults(),
bool  preferSRGBForAuto = false 
)
static


Construct from an explicit set of (optional) mipmaps and (optional) cubemap faces.

bytes[miplevel][cubeface] is a pointer to the bytes for that miplevel and cube face. If the outer array has only one element and the interpolation mode is TRILINEAR_MIPMAP, mip-maps are automatically generated from the level 0 mip-map.

There must be exactly 6 cube faces per mip-level if the dimensions are DIM_CUBE and and 1 per mip-level otherwise. You may specify compressed and uncompressed formats for both the bytesformat and the desiredformat.

3D Textures may not use mip-maps.

Data is converted between normalized fixed point and floating point as described in section 2.1.5 of the OpenGL 3.2 specification. Specifically, uint8 values are converted to floating point by v' = v / 255.0f. Note that this differs from how G3D::Color1uint8 converts to G3D::Color3.

Note: OpenGL stores values at texel centers. Thus element at integer position (x, y) in the input "image" is stored at texture coordinate ((x + 0.5) / width, (x + 0.5) / height).

Referenced by G3D::MapComponent< Image >::getTexture().

◆ fromMemory() [2/2]

static shared_ptr<Texture> G3D::Texture::fromMemory ( const String name,
const void *  bytes,
const ImageFormat bytesFormat,
int  width,
int  height,
int  depth,
int  numSamples = 1,
Encoding  encoding = Encoding(),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults(),
bool  preferSRGBForAuto = false 
)
static

Construct from a single packed 2D or 3D data set.

Shorthand for Texture::fromMemory(name, Array<Array<const void*>> bytes, ...)

◆ fromPixelTransferBuffer()

static shared_ptr<Texture> G3D::Texture::fromPixelTransferBuffer ( const String name,
const shared_ptr< PixelTransferBuffer > &  image,
Encoding  desiredEncoding = Encoding(),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults() 
)
static

◆ fromTwoFiles()

static shared_ptr<Texture> G3D::Texture::fromTwoFiles ( const String filename,
const String alphaFilename,
Encoding  encoding = Encoding(),
Dimension  dimension = DIM_2D,
bool  generateMipMaps = true,
const Preprocess preprocess = Preprocess::defaults(),
bool  preferSRGBForAuto = true,
const bool  useAlpha = false 
)
static


Creates a texture from the colors of filename and takes the alpha values from the red channel of alpha filename if useAlpha is set to true, it will use the alpha channel instead.

See G3D::RenderDevice::setBlendFunc for important information about turning on alpha blending.

◆ generateMipMaps()

void G3D::Texture::generateMipMaps ( )

For a texture with that supports the FrameBufferObject extension, generate mipmaps from the level 0 mipmap immediately.

For other textures, does nothing.

◆ getAllTextures() [1/2]

static void G3D::Texture::getAllTextures ( Array< shared_ptr< Texture >> &  textures)
static

◆ getAllTextures() [2/2]

static void G3D::Texture::getAllTextures ( Array< weak_ptr< Texture >> &  textures)
static

◆ getCubeMapRotation()

static void G3D::Texture::getCubeMapRotation ( CubeFace  face,
Matrix3 outMatrix 
)
static


Returns the rotation matrix that should be used for rendering the given cube map face.

The orientations will seem to have the camera "upside down" compared to what you might expect because OpenGL's cube map convention and texture convention are both inverted from how we usually visualize the data.

The resulting cube maps can be saved to disk by:

const Texture::CubeMapInfo::Face& faceInfo = cubeMapInfo.face[f];
Image temp;
renderTarget->getImage(temp, ImageFormat::RGB8());
temp.flipVertical();
temp.rotate90CW(-faceInfo.rotations);
if (faceInfo.flipY) temp.flipVertical();
if (faceInfo.flipX) temp.flipHorizontal();
temp.save(format("out-%s.png", faceInfo.suffix.c_str()));

◆ getTexImage()

void G3D::Texture::getTexImage ( void *  data,
const ImageFormat desiredFormat,
CubeFace  face = CubeFace::POS_X,
int  mipLevel = 0 
) const
Deprecated:
Use toPixelTransferBuffer

◆ getTextureByName()

static shared_ptr<Texture> G3D::Texture::getTextureByName ( const String textureName)
static

Returns a pointer to a texture with the name textureName, if such a texture exists.

Returns null otherwise. If multiple textures have the name textureName, one is chosen arbitrarily.

This function is not performant, it is linear in the number of existing textures; it is provided for convenience.

◆ hasMipMaps()

bool G3D::Texture::hasMipMaps ( ) const
inline

Referenced by numMipMapLevels().

◆ height()

int G3D::Texture::height ( ) const
inline

Number of horizontal texels in the level 0 mipmap.

◆ isCubeMap()

bool G3D::Texture::isCubeMap ( ) const
inline

Deprecated, use dimension() == Texture::DIM_CUBE_MAP instead.

◆ isSupportedImage()

static bool G3D::Texture::isSupportedImage ( const String filename)
static

Returns true if the specified filename exists and is an image that can be loaded as a Texture.

◆ max()

Color4 G3D::Texture::max ( ) const
inline

If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), then this is the largest value in the texture, modified by the encoding's scale and bias.

NaN if unknown.

◆ mean()

Color4 G3D::Texture::mean ( ) const
inline

If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), then this is the average value in the texture, modified by the encoding's scale and bias.

NaN if unknown.

◆ min()

Color4 G3D::Texture::min ( ) const
inline

If this texture was loaded from an uncompressed format in memory or disk (and not rendered to), this is the smallest value in the texture, modified by the encoding's scale and bias.

NaN if unknown.

◆ name()

const String& G3D::Texture::name ( ) const
inline

For debugging purposes, appears in the texture viewer.

See also
caption

◆ newGLTextureID()

static unsigned int G3D::Texture::newGLTextureID ( )
staticprotected


Helper method.

Returns a new OpenGL texture ID that is not yet managed by a G3D Texture. Used by Texture and G3D::BufferTexture only.

◆ numMipMapLevels()

int G3D::Texture::numMipMapLevels ( )
inline

◆ numSamples()

int G3D::Texture::numSamples ( )
inline

◆ one()

static const shared_ptr<Texture>& G3D::Texture::one ( )
inlinestatic

Returns a small all-white (1,1,1,1) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

◆ opaque()

bool G3D::Texture::opaque ( ) const
inline


True if this texture was created with an alpha channel.

Note that a texture may have a format that is not opaque (e.g., RGBA8) yet still have a completely opaque alpha channel, causing texture->opaque to be true. This is just a flag set for the user's convenience– it does not affect rendering in any way. See G3D::RenderDevice::setBlendFunc for important information about turning on alpha blending.

Referenced by alphaFilter().

◆ opaqueBlack()

static const shared_ptr<Texture>& G3D::Texture::opaqueBlack ( Dimension  d = DIM_2D)
static

Returns a small opaque all-black (0,0,0,1) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

Parameters
dmust be DIM_2D, DIM_3D, or DIM_2D_ARRAY

Referenced by opaqueBlackIfNull(), and G3D::LightingEnvironment::screenColorTexture().

◆ opaqueBlackCube()

static const shared_ptr<Texture>& G3D::Texture::opaqueBlackCube ( )
static

Returns a small opaque all-black (0,0,0,1) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

◆ opaqueBlackIfNull()

static const shared_ptr<Texture>& G3D::Texture::opaqueBlackIfNull ( const shared_ptr< Texture > &  t)
inlinestatic

Returns t if it is non-nullptr, or opaqueBlack() if t is nullptr.

◆ opaqueGray()

static const shared_ptr<Texture>& G3D::Texture::opaqueGray ( )
static

Returns a small all-gray (0.5,0.5,0.5,1) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

Referenced by opaqueGrayIfNull().

◆ opaqueGrayIfNull()

static const shared_ptr<Texture>& G3D::Texture::opaqueGrayIfNull ( const shared_ptr< Texture > &  t)
inlinestatic

Returns t if it is non-nullptr, or gray() if t is nullptr.

◆ openGLID()

unsigned int G3D::Texture::openGLID ( ) const
inline

◆ openGLTextureTarget()

unsigned int G3D::Texture::openGLTextureTarget ( ) const


The OpenGL texture target this binds (e.g.

GL_TEXTURE_2D)

◆ readTexel()

Color4 G3D::Texture::readTexel ( int  ix,
int  iy,
class RenderDevice rd = nullptr,
int  mipLevel = 0,
int  iz = 0,
CubeFace  face = CubeFace::POS_X 
) const

Reads back a single texel.

This is slow because it stalls the CPU on the GPU. However, it requires less bandwidth than reading an entire image.

rd If nullptr, set to RenderDevice::current;

See also
toPixelTransferBuffer

◆ rect2DBounds()

Rect2D G3D::Texture::rect2DBounds ( ) const

Returns a rectangle whose m_width and m_height match the dimensions of the texture.

◆ registerReallocationHook()

void G3D::Texture::registerReallocationHook ( std::function< void(GLuint)>  reallocateHook) const
inline

◆ resize() [1/2]

void G3D::Texture::resize ( int  w,
int  h 
)

Resize the underlying OpenGL texture memory buffer, without reallocating the OpenGL texture ID.

This does not scale the contents; the contents are undefined after resizing. This is only useful for textures that are render targets.

◆ resize() [2/2]

void G3D::Texture::resize ( int  w,
int  h,
int  d 
)

New resize for 3D textures.

◆ setCaption()

void G3D::Texture::setCaption ( const String c)
inline

◆ setName()

void G3D::Texture::setName ( const String n)
inline

◆ setShaderArgs()

void G3D::Texture::setShaderArgs ( class UniformTable args,
const String prefix,
const Sampler sampler 
)

Binds the following uniforms:

  • samplerX prefix##buffer;
  • vecY prefix##size;
  • vecY prefix##invSize;
  • vec4 prefix##readMultiplyFirst;
  • vec4 prefix##readAddSecond;

to args, with X and Y being chosen based on the texture dimension.

If prefix contains no period (deprecated), then the macro is bound:

#define prefix##notNull 1

otherwise,

bool prefix##notNull

is set to true.

Inside a shader, these arguments can be automatically defined using the macro (deprecated)

#include &lt;Texture/Texture.glsl&gt;
uniform_Texture(samplerType, name_)

or by using a struct

#include &lt;Texture/Texture.glsl&gt;
uniform Texture2D name;
See also
uniform_Texture

◆ singleChannelDifference()

static shared_ptr<Texture> G3D::Texture::singleChannelDifference ( RenderDevice rd,
const shared_ptr< Texture > &  t0,
const shared_ptr< Texture > &  t1,
int  channel = 0 
)
static

Returns an RG32F difference texture of the same dimensions as t0 and t1 of (t0 - t1) of the specified channel, with positive values in the red channel and negative values in the green.

Expect changes to this API as we use it more and make it more manageable

◆ sizeInMemory()

int G3D::Texture::sizeInMemory ( ) const


How much (texture) memory this texture occupies.

OpenGL backs video memory textures with main memory, so the total memory is actually twice this number.

◆ sizeOfAllTexturesInMemory()

static int64 G3D::Texture::sizeOfAllTexturesInMemory ( )
inlinestatic


Video memory occupied by all OpenGL textures allocated using Texture or maintained by pointers to a Texture.

◆ sphereRandom()

static shared_ptr<Texture> G3D::Texture::sphereRandom ( )
static

Returns a texture of 1024^2 oct32-encoded uniformly distributed random vectors on the sphere.

Use octDecode(texelFetch(g3d_sphereRandom, pos, 0).xy) in a shader to decode these. This is automatically bound as g3d_sphereRandom in shaders that use it.

◆ splitFilenameAtWildCard()

static void G3D::Texture::splitFilenameAtWildCard ( const String filename,
String filenameBeforeWildCard,
String filenameAfterWildCard 
)
static


Splits a filename around the '*' character– used by cube maps to generate all filenames.

◆ supportsWrapMode()

static bool G3D::Texture::supportsWrapMode ( WrapMode  m)
inlinestatic


Returns true if this is a legal wrap mode for a G3D::Texture.

◆ texelType()

TexelType G3D::Texture::texelType ( ) const

◆ toCubeMap()

shared_ptr<class CubeMap> G3D::Texture::toCubeMap ( ) const

◆ toDepthImage1unorm8()

shared_ptr<Image1unorm8> G3D::Texture::toDepthImage1unorm8 ( ) const

Extracts the data as ImageFormat::DEPTH32F and converts to 8-bit.

Note that you may want to call Image1unorm8::flipVertical afterward.

◆ toDepthMap()

shared_ptr<Map2D<float> > G3D::Texture::toDepthMap ( ) const

Extracts the data as ImageFormat::DEPTH32F.

◆ toDepthReadMode()

static DepthReadMode G3D::Texture::toDepthReadMode ( const String s)
static

◆ toDimension()

static Dimension G3D::Texture::toDimension ( const String s)
static

◆ toImage()

shared_ptr<Image> G3D::Texture::toImage ( const ImageFormat outFormat = ImageFormat::AUTO(),
int  mipLevel = 0,
CubeFace  face = CubeFace::POS_X 
) const

◆ toPixelTransferBuffer() [1/2]

shared_ptr<GLPixelTransferBuffer> G3D::Texture::toPixelTransferBuffer ( const ImageFormat outFormat = ImageFormat::AUTO(),
int  mipLevel = 0,
CubeFace  face = CubeFace::POS_X 
) const

◆ toPixelTransferBuffer() [2/2]

void G3D::Texture::toPixelTransferBuffer ( shared_ptr< GLPixelTransferBuffer > &  buffer,
const ImageFormat outFormat = ImageFormat::AUTO(),
int  mipLevel = 0,
CubeFace  face = CubeFace::POS_X,
bool  runMapHooks = true 
) const

◆ toString() [1/2]

static const char* G3D::Texture::toString ( DepthReadMode  m)
static

◆ toString() [2/2]

static const char* G3D::Texture::toString ( Dimension  m)
static

◆ uniformRandom()

static shared_ptr<Texture> G3D::Texture::uniformRandom ( )
static

Returns a texture of 1024^2 RG16 vectors of uniformly distributed random numbers: ([0,1], [0,1]).

This is automatically bound as g3d_uniformRandom in shaders that use it.

◆ update()

void G3D::Texture::update ( const shared_ptr< PixelTransferBuffer > &  src,
int  mipLevel = 0,
CubeFace  face = CubeFace::POS_X,
bool  runMapHooks = true,
size_t  byteOffset = 0,
bool  resizeTexture = true 
)

Upload new data from the CPU to this texture.

Corresponds to glTexSubImage2D. If src is smaller than the current dimensions of this, only part of this is updated.

This routine does not provide the same protections as creating a new Texture from memory: you must handle scaling and ensure compatible formats yourself.

Parameters
faceIf specified, determines the cubemap face to copy into
srcGLPixelTransferBuffer is handled specially to support updates when the buffer is not yet PixelTransferBuffer::readyToMap. All other PixelTransferBuffers are mapped for read. The upload to the GPU is asynchronous (assuming that the GPU driver is reasonable) and the buffer may be modified immediately on return.

◆ vector2Bounds()

Vector2 G3D::Texture::vector2Bounds ( ) const
inline

◆ white()

static const shared_ptr<Texture>& G3D::Texture::white ( )
static

Returns a small all-white (1,1,1,1) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

Referenced by one(), and whiteIfNull().

◆ whiteCube()

static const shared_ptr<Texture>& G3D::Texture::whiteCube ( )
static

Returns a small all-white (1,1,1,1) cube map texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

The underlying OpenGL texture is guaranteed not to be deallocated before RenderDevice shuts down.

Referenced by whiteCubeIfNull().

◆ whiteCubeIfNull()

static const shared_ptr<Texture>& G3D::Texture::whiteCubeIfNull ( const shared_ptr< Texture > &  t)
inlinestatic

Returns t if it is non-nullptr, or whiteCube() if t is nullptr.

◆ whiteIfNull()

static const shared_ptr<Texture>& G3D::Texture::whiteIfNull ( const shared_ptr< Texture > &  t)
inlinestatic

Returns t if it is non-nullptr, or white() if t is nullptr.

◆ width()

int G3D::Texture::width ( ) const
inline

Number of horizontal texels in the level 0 mipmap.

◆ zero()

static const shared_ptr<Texture>& G3D::Texture::zero ( Dimension  d = DIM_2D)
static

Returns a small, all zero Color4(0,0,0,0) texture.

The result is memoized and shared. Do not mutate this texture or future calls will return the mutated texture as well.

Parameters
dmust be DIM_2D, DIM_3D, or DIM_2D_ARRAY

Referenced by zeroIfNull().

◆ zeroIfNull()

static const shared_ptr<Texture>& G3D::Texture::zeroIfNull ( const shared_ptr< Texture > &  t)
inlinestatic

Returns t if it is non-nullptr, or zero() if t is nullptr.

Friends And Related Function Documentation

◆ BufferTexture

friend class BufferTexture
friend

◆ Component

template<class C , class I >
friend class Component
friend

◆ GLSamplerObject

friend class GLSamplerObject
friend

◆ MapComponent

template<class I >
friend class MapComponent
friend

◆ Shader

friend class Shader
friend

Member Data Documentation

◆ m_appearsInTextureBrowserWindow

bool G3D::Texture::m_appearsInTextureBrowserWindow
protected

If true, this texture can be registered in the TextureBrowser for run-time debugging.

Referenced by appearsInTextureBrowserWindow().

◆ m_cachedSamplerSettings

Sampler G3D::Texture::m_cachedSamplerSettings
protected

◆ m_caption

String G3D::Texture::m_caption
protected

Referenced by setCaption().

◆ m_conservativelyHasNonUnitAlpha

bool G3D::Texture::m_conservativelyHasNonUnitAlpha = false
protected

◆ m_conservativelyHasUnitAlpha

bool G3D::Texture::m_conservativelyHasUnitAlpha = false
protected

◆ m_depth

int G3D::Texture::m_depth
protected

Referenced by depth(), and numMipMapLevels().

◆ m_destroyGLTextureInDestructor

bool G3D::Texture::m_destroyGLTextureInDestructor
protected

True if the GL texture is owned by the instance and should be cleaned up with the class instance.

◆ m_detectedHint

AlphaFilter G3D::Texture::m_detectedHint
protected

What AlphaFilter::DETECT should resolve to for this texture.

Left as DETECT if not computed.

Referenced by alphaFilter().

◆ m_dimension

Dimension G3D::Texture::m_dimension
protected

Referenced by dimension(), and isCubeMap().

◆ m_encoding

Encoding G3D::Texture::m_encoding
protected

Referenced by encoding(), format(), max(), mean(), min(), and opaque().

◆ m_hasMipMaps

bool G3D::Texture::m_hasMipMaps
protected

Referenced by hasMipMaps().

◆ m_height

int G3D::Texture::m_height
protected

◆ m_loadingInfo

LoadingInfo* G3D::Texture::m_loadingInfo = nullptr
mutableprotected

◆ m_loadingMutex

std::mutex G3D::Texture::m_loadingMutex
mutableprotected

Protects m_needsForce, m_loadingThread, and m_loadingGLCallback.

See also
force()

◆ m_loadingThread

std::thread* G3D::Texture::m_loadingThread = nullptr
mutableprotected

The thread that lazy loads into memory by invoking the m_loadingCPUCallbackQueue callbacks.

Not permitted to make any OpenGL calls. Mutable so that it can be deallocated during the const force() method.

The loading thread advances through m_loadingInfo.nextStep processing until it reaches the UPLOAD_TO_GPU stage. That must be run during force on the GL thread.

See also
force()

◆ m_max

Color4 G3D::Texture::m_max
protected

Invoke force() before accessing.

Does not factor in the encoding's scaling.

Referenced by max().

◆ m_mean

Color4 G3D::Texture::m_mean
protected

Invoke force() before accessing.

Does not factor in the encoding's scaling.

Referenced by mean().

◆ m_min

Color4 G3D::Texture::m_min
protected

Invoke force() before accessing.

Does not factor in the encoding's scaling.

Referenced by min().

◆ m_name

String G3D::Texture::m_name
protected

Referenced by name(), and setName().

◆ m_needsForce

volatile bool G3D::Texture::m_needsForce = false
mutableprotected

If true, this Texture is waiting for loading and/or upload to the GPU.

Set by certain lazy initialization paths of Texture::fromFile. This is protected by m_loadingMutex, but can be conservatively checked for the false case without a mutex for efficiency. Mutable so that it can be written during the const force() method.

See also
force()

◆ m_numSamples

int G3D::Texture::m_numSamples
protected

Multi-sampled texture parameters.

Referenced by numSamples().

◆ m_opaque

bool G3D::Texture::m_opaque
protected

Referenced by opaque().

◆ m_reallocateHook

shared_ptr<std::function<void(GLuint)> > G3D::Texture::m_reallocateHook
mutableprotected

◆ m_sizeOfAllTexturesInMemory

int64 G3D::Texture::m_sizeOfAllTexturesInMemory
staticprotected

◆ m_textureID

GLuint G3D::Texture::m_textureID
protected

OpenGL texture ID.

Always invoke force() before accessing this.

Referenced by openGLID().

◆ m_width

int G3D::Texture::m_width
protected

◆ s_allTextures

WeakCache<uintptr_t, shared_ptr<Texture> > G3D::Texture::s_allTextures
staticprotected

Used for the Texture browser.

nullptr elements are flushed during reloadAll(). The key is the raw pointer.

◆ s_cache

WeakCache<Specification, shared_ptr<Texture> > G3D::Texture::s_cache
staticprotected

Used to avoid re-loading textures.

◆ visualization

Visualization G3D::Texture::visualization

Used to display this Texture in a GuiTextureBox.


documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15