Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Graphic::Resource::Texture Class Reference

#include <Texture.hpp>

Public Member Functions

 Texture (std::string_view name, wgpu::Texture texture, bool ownsResources=true)
 Texture (const Context &context, const wgpu::TextureDescriptor &descriptor)
 Texture (const Context &context, std::string_view name, const Image &image)
 Texture (const Context &context, std::string_view name, const glm::uvec2 &size, const std::function< glm::u8vec4(glm::uvec2 pos)> &callback)
 ~Texture ()
 Texture (const Texture &)=delete
Textureoperator= (const Texture &)=delete
 Texture (Texture &&other) noexcept
Textureoperator= (Texture &&other) noexcept
glm::uvec2 GetSize () const
void Write (const Context &context, const Image &image)
Image RetrieveImage (const Context &context) const
 Reads back the GPU texture and returns it as an Image.
wgpu::TextureView GetDefaultView () const
wgpu::TextureView CreateView (const wgpu::TextureViewDescriptor &descriptor) const
void ReleaseOwnership ()
void TakeOwnership ()
bool OwnsResources () const

Private Member Functions

 Texture (void)=default
uint32_t _GetBytesPerPixel () const

Static Private Member Functions

static wgpu::TextureDescriptor _BuildDescriptor (std::string_view name, const Image &image)

Private Attributes

wgpu::Texture _webgpuTexture
wgpu::TextureView _defaultView
std::string _name
bool _ownsResources = true

Constructor & Destructor Documentation

◆ Texture() [1/7]

Graphic::Resource::Texture::Texture ( std::string_view name,
wgpu::Texture texture,
bool ownsResources = true )
inline

◆ Texture() [2/7]

Graphic::Resource::Texture::Texture ( const Context & context,
const wgpu::TextureDescriptor & descriptor )
inline

◆ Texture() [3/7]

Graphic::Resource::Texture::Texture ( const Context & context,
std::string_view name,
const Image & image )
inline

◆ Texture() [4/7]

Graphic::Resource::Texture::Texture ( const Context & context,
std::string_view name,
const glm::uvec2 & size,
const std::function< glm::u8vec4(glm::uvec2 pos)> & callback )
inline

◆ ~Texture()

Graphic::Resource::Texture::~Texture ( )
inline

◆ Texture() [5/7]

Graphic::Resource::Texture::Texture ( const Texture & )
delete

◆ Texture() [6/7]

Graphic::Resource::Texture::Texture ( Texture && other)
inlinenoexcept

◆ Texture() [7/7]

Graphic::Resource::Texture::Texture ( void )
privatedefault

Member Function Documentation

◆ _BuildDescriptor()

wgpu::TextureDescriptor Graphic::Resource::Texture::_BuildDescriptor ( std::string_view name,
const Image & image )
inlinestaticprivate

◆ _GetBytesPerPixel()

uint32_t Graphic::Resource::Texture::_GetBytesPerPixel ( ) const
inlineprivate

◆ CreateView()

wgpu::TextureView Graphic::Resource::Texture::CreateView ( const wgpu::TextureViewDescriptor & descriptor) const
inline

◆ GetDefaultView()

wgpu::TextureView Graphic::Resource::Texture::GetDefaultView ( ) const
inline

◆ GetSize()

glm::uvec2 Graphic::Resource::Texture::GetSize ( ) const
inline

◆ operator=() [1/2]

Texture & Graphic::Resource::Texture::operator= ( const Texture & )
delete

◆ operator=() [2/2]

Texture & Graphic::Resource::Texture::operator= ( Texture && other)
inlinenoexcept

◆ OwnsResources()

bool Graphic::Resource::Texture::OwnsResources ( ) const
inline

◆ ReleaseOwnership()

void Graphic::Resource::Texture::ReleaseOwnership ( )
inline

◆ RetrieveImage()

Image Graphic::Resource::Texture::RetrieveImage ( const Context & context) const
inline

Reads back the GPU texture and returns it as an Image.

Copies the texture to a CPU-readable buffer, converts the source texel format into 4-channel RGBA byte pixels, and returns an Image populated with those pixels. Depth formats are mapped to grayscale RGBA (depth -> luminance, alpha = 255).

Returns
Image The retrieved image with width and height matching the texture and 4 channels (RGBA).

◆ TakeOwnership()

void Graphic::Resource::Texture::TakeOwnership ( )
inline

◆ Write()

void Graphic::Resource::Texture::Write ( const Context & context,
const Image & image )
inline

Member Data Documentation

◆ _defaultView

wgpu::TextureView Graphic::Resource::Texture::_defaultView
private

◆ _name

std::string Graphic::Resource::Texture::_name
private

◆ _ownsResources

bool Graphic::Resource::Texture::_ownsResources = true
private

◆ _webgpuTexture

wgpu::Texture Graphic::Resource::Texture::_webgpuTexture
private

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