Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::glTexture Class Referencefinal

#include <glTexture.h>

+ Inheritance diagram for Divide::glTexture:

Public Member Functions

 glTexture (PlatformContext &context, const ResourceDescriptor< Texture > &descriptor)
 
 ~glTexture () override
 
bool unload () override
 
void clearData (const UColour4 &clearColour, SubRange layerRange, U8 mipLevel) const
 
ImageReadbackData readData (U8 mipLevel, const PixelAlignment &pixelPackAlignment) const override
 
 PROPERTY_R_IW (gl46core::GLuint, textureHandle, GL_NULL_HANDLE)
 
- Public Member Functions inherited from Divide::Texture
 Texture (PlatformContext &context, const ResourceDescriptor< Texture > &descriptor)
 
virtual ~Texture () override
 
void createWithData (const ImageTools::ImageData &imageData, const PixelAlignment &pixelUnpackAlignment)
 API-dependent loading function that uploads ptr data to the GPU using the specified parameters.
 
void createWithData (const Byte *data, size_t dataSize, const vec2< U16 > &dimensions, const PixelAlignment &pixelUnpackAlignment)
 
void createWithData (const Byte *data, size_t dataSize, const vec3< U16 > &dimensions, const PixelAlignment &pixelUnpackAlignment)
 
void replaceData (const Byte *data, size_t dataSize, const vec3< U16 > &offset, const vec3< U16 > &range, const PixelAlignment &pixelUnpackAlignment)
 
void setSampleCount (U8 newSampleCount)
 Change the number of MSAA samples for this current texture.
 
ImageView getView () const noexcept
 
ImageView getView (TextureType targetType) const noexcept
 
ImageView getView (SubRange mipRange) const noexcept
 
ImageView getView (SubRange mipRange, SubRange layerRange) const noexcept
 
ImageView getView (TextureType targetType, SubRange mipRange) const noexcept
 
ImageView getView (TextureType targetType, SubRange mipRange, SubRange layerRange) const noexcept
 
virtual ImageReadbackData readData (U8 mipLevel, const PixelAlignment &pixelPackAlignment) const =0
 
 PROPERTY_R (TextureDescriptor, descriptor)
 
 PROPERTY_R (U16, mipCount, 1u)
 Get the number of mips.
 
 PROPERTY_R (U16, width, 0u)
 Texture width as returned by STB/DDS loader.
 
 PROPERTY_R (U16, height, 0u)
 Texture height as returned by STB/DDS loader.
 
 PROPERTY_R (U16, depth, 1u)
 Depth for TEXTURE_3D, layer count for TEXTURE_1/2D/CUBE_ARRAY. For cube arrays, numSlices = depth * 6u.
 
 PROPERTY_R (bool, hasTranslucency, false)
 If the texture has an alpha channel and at least one pixel is translucent, return true.
 
 PROPERTY_R (bool, hasTransparency, false)
 If the texture has an alpha channel and at least on pixel is fully transparent and no pixels are partially transparent, return true.
 
 PROPERTY_R (bool, loadedFromFile, false)
 
U8 numChannels () const noexcept
 
bool load (PlatformContext &context) override
 Loading and unloading interface.
 
bool postLoad () override
 
- Public Member Functions inherited from Divide::CachedResource
 CachedResource (const ResourceDescriptorBase &descriptor, std::string_view typeName)
 
virtual bool load (PlatformContext &context)
 Loading and unloading interface.
 
virtual bool postLoad ()
 
virtual bool unload ()
 
void setState (ResourceState currentState) final
 
- Public Member Functions inherited from Divide::Resource
 Resource (std::string_view resourceName, std::string_view typeName)
 
ResourceState getState () const noexcept
 
 PROPERTY_R (Str< 32 >, typeName)
 
 PROPERTY_R (Str< 256 >, resourceName)
 
- Public Member Functions inherited from Divide::GUIDWrapper
 GUIDWrapper () noexcept
 
 GUIDWrapper (const GUIDWrapper &old) noexcept
 
 GUIDWrapper (GUIDWrapper &&old) noexcept
 
virtual ~GUIDWrapper ()=default
 
FORCE_INLINE I64 getGUID () const noexcept
 
GUIDWrapperoperator= (const GUIDWrapper &old)=delete
 
GUIDWrapperoperator= (GUIDWrapper &&other)=delete
 
- Public Member Functions inherited from Divide::GraphicsResource
virtual ~GraphicsResource ()
 
GFXDevicecontext () const noexcept
 
U64 nameHash () const noexcept
 
- Public Member Functions inherited from Divide::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from Divide::NonMovable
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 

Static Public Member Functions

static void Copy (const glTexture *source, U8 sourceSamples, const glTexture *destination, U8 destinationSamples, const CopyTexParams &params)
 
- Static Public Member Functions inherited from Divide::Texture
static void OnStartup (GFXDevice &gfx)
 
static void OnShutdown () noexcept
 
static bool UseTextureDDSCache () noexcept
 
static Handle< TextureDefaultTexture2D () noexcept
 
static Handle< TextureDefaultTexture2DArray () noexcept
 
static const SamplerDescriptor DefaultSampler () noexcept
 
static U8 GetBytesPerPixel (GFXDataFormat format, GFXImageFormat baseFormat, GFXImagePacking packing) noexcept
 
- Static Public Member Functions inherited from Divide::GUIDWrapper
static I64 generateGUID () noexcept
 

Protected Member Functions

bool postLoad () override
 
void reserveStorage ()
 
void loadDataInternal (const ImageTools::ImageData &imageData, const vec3< U16 > &offset, const PixelAlignment &pixelUnpackAlignment) override
 
void loadDataInternal (const Byte *data, size_t size, U8 targetMip, const vec3< U16 > &offset, const vec3< U16 > &dimensions, const PixelAlignment &pixelUnpackAlignment) override
 
void prepareTextureData (U16 width, U16 height, U16 depth, bool emptyAllocation) override
 
void submitTextureData () override
 
- Protected Member Functions inherited from Divide::Texture
bool loadFile (const ResourcePath &path, std::string_view name, ImageTools::ImageData &fileData)
 Use STB to load a file into a Texture Object.
 
bool checkTransparency (const ResourcePath &path, std::string_view name, ImageTools::ImageData &fileData)
 
bool loadInternal ()
 Load texture data using the specified file name.
 
void validateDescriptor ()
 
virtual void loadDataInternal (const ImageTools::ImageData &imageData, const vec3< U16 > &offset, const PixelAlignment &pixelUnpackAlignment)=0
 
virtual void loadDataInternal (const Byte *data, size_t size, U8 targetMip, const vec3< U16 > &offset, const vec3< U16 > &dimensions, const PixelAlignment &pixelUnpackAlignment)=0
 
virtual void prepareTextureData (U16 width, U16 height, U16 depth, bool emptyAllocation)
 
virtual void submitTextureData ()
 
- Protected Member Functions inherited from Divide::CachedResource
 PROPERTY_RW (ResourcePath, assetLocation)
 
 PROPERTY_RW (Str< 256 >, assetName)
 
 PROPERTY_R (size_t, descriptorHash)
 
virtual void setState (ResourceState currentState)
 
- Protected Member Functions inherited from Divide::GraphicsResource
 GraphicsResource (GFXDevice &context, Type type, I64 GUID, U64 nameHash)
 
- Protected Member Functions inherited from Divide::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Protected Member Functions inherited from Divide::NonMovable
 NonMovable ()=default
 
 ~NonMovable ()=default
 

Private Attributes

gl46core::GLenum _type { gl46core::GL_NONE}
 
gl46core::GLuint _loadingHandle { GL_NULL_HANDLE }
 
gl46core::GLsync _loadSync { nullptr }
 
bool _hasStorage { false }
 

Additional Inherited Members

- Public Types inherited from Divide::GraphicsResource
enum class  Type : U8 {
  RENDER_TARGET , SHADER_BUFFER , BUFFER , SHADER ,
  SHADER_PROGRAM , TEXTURE , COUNT
}
 
- Protected Attributes inherited from Divide::CachedResource
Mutex _callbackLock {}
 
- Protected Attributes inherited from Divide::Resource
std::atomic< ResourceState_resourceState
 
- Protected Attributes inherited from Divide::GUIDWrapper
const I64 _guid
 
- Protected Attributes inherited from Divide::GraphicsResource
GFXDevice_context
 
- Static Protected Attributes inherited from Divide::Texture
static bool s_useDDSCache = true
 
static SamplerDescriptor s_defaultSampler
 
static Handle< Textures_defaultTexture2D = INVALID_HANDLE<Texture>
 
static Handle< Textures_defaultTexture2DArray = INVALID_HANDLE<Texture>
 
static Str< 64 > s_missingTextureFileName
 

Detailed Description

Definition at line 42 of file glTexture.h.

Constructor & Destructor Documentation

◆ glTexture()

Divide::glTexture::glTexture ( PlatformContext context,
const ResourceDescriptor< Texture > &  descriptor 
)
explicit

Definition at line 13 of file glTexture.cpp.

◆ ~glTexture()

Divide::glTexture::~glTexture ( )
override

Definition at line 20 of file glTexture.cpp.

Member Function Documentation

◆ clearData()

void Divide::glTexture::clearData ( const UColour4 clearColour,
SubRange  layerRange,
U8  mipLevel 
) const

Definition at line 280 of file glTexture.cpp.

◆ Copy()

void Divide::glTexture::Copy ( const glTexture source,
U8  sourceSamples,
const glTexture destination,
U8  destinationSamples,
const CopyTexParams params 
)
static

Definition at line 366 of file glTexture.cpp.

◆ loadDataInternal() [1/2]

void Divide::glTexture::loadDataInternal ( const Byte data,
size_t  size,
U8  targetMip,
const vec3< U16 > &  offset,
const vec3< U16 > &  dimensions,
const PixelAlignment pixelUnpackAlignment 
)
overrideprotectedvirtual

Implements Divide::Texture.

Definition at line 213 of file glTexture.cpp.

◆ loadDataInternal() [2/2]

void Divide::glTexture::loadDataInternal ( const ImageTools::ImageData imageData,
const vec3< U16 > &  offset,
const PixelAlignment pixelUnpackAlignment 
)
overrideprotectedvirtual

Implements Divide::Texture.

Definition at line 195 of file glTexture.cpp.

◆ postLoad()

bool Divide::glTexture::postLoad ( )
overrideprotectedvirtual

Reimplemented from Divide::CachedResource.

Definition at line 41 of file glTexture.cpp.

◆ prepareTextureData()

void Divide::glTexture::prepareTextureData ( U16  width,
U16  height,
U16  depth,
bool  emptyAllocation 
)
overrideprotectedvirtual

Reimplemented from Divide::Texture.

Definition at line 147 of file glTexture.cpp.

◆ PROPERTY_R_IW()

Divide::glTexture::PROPERTY_R_IW ( gl46core::GLuint  ,
textureHandle  ,
GL_NULL_HANDLE   
)

◆ readData()

ImageReadbackData Divide::glTexture::readData ( U8  mipLevel,
const PixelAlignment pixelPackAlignment 
) const
overridevirtual

Implements Divide::Texture.

Definition at line 410 of file glTexture.cpp.

◆ reserveStorage()

void Divide::glTexture::reserveStorage ( )
protected

Definition at line 54 of file glTexture.cpp.

◆ submitTextureData()

void Divide::glTexture::submitTextureData ( )
overrideprotectedvirtual

Reimplemented from Divide::Texture.

Definition at line 165 of file glTexture.cpp.

◆ unload()

bool Divide::glTexture::unload ( )
overridevirtual

Reimplemented from Divide::CachedResource.

Definition at line 25 of file glTexture.cpp.

Member Data Documentation

◆ _hasStorage

bool Divide::glTexture::_hasStorage { false }
private

Definition at line 71 of file glTexture.h.

◆ _loadingHandle

gl46core::GLuint Divide::glTexture::_loadingHandle { GL_NULL_HANDLE }
private

Definition at line 69 of file glTexture.h.

◆ _loadSync

gl46core::GLsync Divide::glTexture::_loadSync { nullptr }
private

Definition at line 70 of file glTexture.h.

◆ _type

gl46core::GLenum Divide::glTexture::_type { gl46core::GL_NONE}
private

Definition at line 68 of file glTexture.h.


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