Ritchie's Abstractions 0.2
Platform abstractions that make Toolbox work
Loading...
Searching...
No Matches
Texture2D Class Referencesealed

Class representing a 2D image. More...

Inheritance diagram for Texture2D:
Texture GraphicsObject

Public Member Functions

 Texture2D (int width, int height, SurfaceFormat surfaceFormat, PixelFormat pixelFormat)
 Creates a new Texture2D.
 
void GetData (in Span< byte > data)
 Get the surface data for this texture.
 
void SetData (in ReadOnlySpan< byte > data)
 Set the surface data for this texture.
 
void SetData (in ReadOnlySpan< byte > data, Rectangle region)
 Set the surface data of the given region within the texture.
 
void SetData (in ReadOnlySpan< float > data)
 
void SetData (in ReadOnlySpan< uint > data)
 
void SetData (in ReadOnlySpan< int > data)
 
void SetData (in ReadOnlySpan< float > data, Rectangle region)
 
void SetData (in ReadOnlySpan< uint > data, Rectangle region)
 
void SetData (in ReadOnlySpan< int > data, Rectangle region)
 
void SetData (in ReadOnlySpan< Color > data)
 
void SetData (in ReadOnlySpan< Color > data, Rectangle region)
 
- Public Member Functions inherited from GraphicsObject
void Dispose ()
 

Static Public Member Functions

static Texture2D FromStream (Stream stream)
 Creates a Texture2D by reading image data from the supplied stream.
 

Protected Member Functions

override void Dispose (bool disposing)
 Called when it's time to throw out the trash.
Parameters
disposingIf true, please throw away your trash. Skunks!

 
- Protected Member Functions inherited from GraphicsObject
 GraphicsObject ()
 Creates a new GraphicsObject instance.
 

Properties

int Width [get]
 Gets the width of this texture.
 
int Height [get]
 Gets the height of this texture.
 
- Properties inherited from GraphicsObject
GraphicsDevice GraphicsDevice [get]
 Gets the GraphicsDevice instance this GraphicsObject belongs to.
 

Detailed Description

Class representing a 2D image.

Constructor & Destructor Documentation

◆ Texture2D()

Texture2D ( int width,
int height,
SurfaceFormat surfaceFormat,
PixelFormat pixelFormat )
inline

Creates a new Texture2D.

Parameters
widthThe width of the texture in pixels.
heightThe height of the texture in pixels.
surfaceFormat
pixelFormat

Member Function Documentation

◆ Dispose()

override void Dispose ( bool disposing)
inlineprotectedvirtual

Called when it's time to throw out the trash.

Parameters
disposingIf true, please throw away your trash. Skunks!

Reimplemented from GraphicsObject.

◆ FromStream()

static Texture2D FromStream ( Stream stream)
inlinestatic

Creates a Texture2D by reading image data from the supplied stream.

Parameters
streamAny readable stream.
Returns
A new Texture2D containing pixel data decoded from the image stream.

If all you want to do is load a PNG or JPEG image from disk and get it on the GPU, this is the function for you.

Simple and speedy functionality brought to you in part by every engine dev's first choice, the library that makes your computer go vroom vroom, stb_image.

◆ GetData()

void GetData ( in Span< byte > data)
inline

Get the surface data for this texture.

Parameters
dataA slice of memory to store the surface data of the texture. Must be exactly Width * Height * BytesPerPixel bytes in size.

◆ SetData() [1/2]

void SetData ( in ReadOnlySpan< byte > data)
inline

Set the surface data for this texture.

Parameters
dataA slice of memory containing the surface data of the texture. Must be exactly Width * Height * BytesPerPixel bytes in size.

◆ SetData() [2/2]

void SetData ( in ReadOnlySpan< byte > data,
Rectangle region )
inline

Set the surface data of the given region within the texture.

Parameters
dataA slice of memory containing the data to upload to the surface. Must be region.Width * region.Height * BytesPerPixel bytes long.
regionA rectangular region within the texture where the given surface data should be uploaded.

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