Interface ISurfaces
GPU Surface Operations Texture and Render Target Creation and Destruction A surface is either a Texture or a RenderTarget A RenderTarget can be drawn too, a Texture cannot Both RenderTarget and Textures can be used as Textures (pixel sources)
Namespace: Yak2D
Assembly: Yak2D.Api.dll
Syntax
public interface ISurfaces
Properties
TotalUserSurfaceCount
Surfaces includes all Textures and RenderTargets
Declaration
int TotalUserSurfaceCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
UserRenderTargetCount
Render Targets can be drawn too, and used in place of textures as a source of pixel data
Declaration
int UserRenderTargetCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
UserTextureCount
Declaration
int UserTextureCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
CreateFloat32FromData(UInt32, UInt32, Single[], SamplerType)
Declaration
ITexture CreateFloat32FromData(uint textureWidth, uint textureHeight, float[] pixels, SamplerType samplerType = SamplerType.Anisotropic)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | textureWidth | |
| System.UInt32 | textureHeight | |
| System.Single[] | pixels | |
| SamplerType | samplerType |
Returns
| Type | Description |
|---|---|
| ITexture |
CreateRenderTarget(UInt32, UInt32, Boolean, SamplerType, UInt32)
Create a GPU drawing surface. RenderTargets can be sampled inplace of Textures
Declaration
IRenderTarget CreateRenderTarget(uint width, uint height, bool autoClearColourAndDepthEachFrame = true, SamplerType samplerType = SamplerType.Anisotropic, uint numberOfMipMapLevels = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | width | Width in pixels |
| System.UInt32 | height | Height in pixels |
| System.Boolean | autoClearColourAndDepthEachFrame | Instruct the framework to clear the depth and colour pixel data of the render target before each render iteration. Helps ensure the user does not forget too |
| SamplerType | samplerType | When the Render Target is sampled as a texture, which sampler filter should be used |
| System.UInt32 | numberOfMipMapLevels | How many MipMap levels should be created (>0, 1 for none) |
Returns
| Type | Description |
|---|---|
| IRenderTarget |
CreateRgbaFromData(UInt32, UInt32, Vector4[], SamplerType, Boolean)
Declaration
ITexture CreateRgbaFromData(uint textureWidth, uint textureHeight, Vector4[] pixels, SamplerType samplerType = SamplerType.Anisotropic, bool generateMipMaps = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | textureWidth | |
| System.UInt32 | textureHeight | |
| Vector4[] | pixels | |
| SamplerType | samplerType | |
| System.Boolean | generateMipMaps |
Returns
| Type | Description |
|---|---|
| ITexture |
DestoryAllUserSurfaces()
Destroy all user surfaces (render targets and textures)
Declaration
void DestoryAllUserSurfaces()
DestroyAllUserRenderTargets()
Destroy all user render targets
Declaration
void DestroyAllUserRenderTargets()
DestroyAllUserTextures()
Destroy all user textures
Declaration
void DestroyAllUserTextures()
DestroySurface(UInt64)
Remove surface object data from framework
Declaration
void DestroySurface(ulong surface)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | surface | The surface (RenderTarget or Texture) id to destroy |
DestroySurface(ITexture)
Remove surface object data from framework
Declaration
void DestroySurface(ITexture surface)
Parameters
| Type | Name | Description |
|---|---|---|
| ITexture | surface | The surface (RenderTarget or Texture) reference to destroy |
GetSurfaceDimensions(UInt64)
Return dimensions of a surface
Declaration
Size GetSurfaceDimensions(ulong surface)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | surface | Surface (Texture or RenderTarget) id |
Returns
| Type | Description |
|---|---|
| Size |
GetSurfaceDimensions(ITexture)
Return dimensions of a surface
Declaration
Size GetSurfaceDimensions(ITexture surface)
Parameters
| Type | Name | Description |
|---|---|---|
| ITexture | surface | Surface (Texture or RenderTarget) reference |
Returns
| Type | Description |
|---|---|
| Size |
LoadTexture(Stream, SamplerType, Boolean)
Declaration
ITexture LoadTexture(Stream stream, SamplerType samplerType = SamplerType.Anisotropic, bool generateMipMaps = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | |
| SamplerType | samplerType | |
| System.Boolean | generateMipMaps |
Returns
| Type | Description |
|---|---|
| ITexture |
LoadTexture(String, AssetSourceEnum, ImageFormat, SamplerType, Boolean)
Declaration
ITexture LoadTexture(string path, AssetSourceEnum assetType, ImageFormat imageFormat = ImageFormat.PNG, SamplerType samplerType = SamplerType.Anisotropic, bool generateMipMaps = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | |
| AssetSourceEnum | assetType | |
| ImageFormat | imageFormat | |
| SamplerType | samplerType | |
| System.Boolean | generateMipMaps |
Returns
| Type | Description |
|---|---|
| ITexture |
LoadTextureColourData(String, AssetSourceEnum, ImageFormat)
Loads texture colour data from a .png image asset
Declaration
TextureData LoadTextureColourData(string path, AssetSourceEnum assetType, ImageFormat imageFormat = ImageFormat.PNG)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | Image (.png) asset name including path (no file extension)" |
| AssetSourceEnum | assetType | Embedded in the binary or a file location" |
| ImageFormat | imageFormat | Image file encoding" |
Returns
| Type | Description |
|---|---|
| TextureData |
ReturnMainWindowRenderTarget()
Returns the RenderTarget reference of the current window's main rendering surface
Declaration
IRenderTarget ReturnMainWindowRenderTarget()
Returns
| Type | Description |
|---|---|
| IRenderTarget |
SetMainWindowRenderTargetAutoClearColour(Boolean)
Modify whether the framework clears the main window render target colour at the start of each draw frame Automatic clearing of colour sets pixels to RGBA 0,0,0,0 (transparent black)
Declaration
void SetMainWindowRenderTargetAutoClearColour(bool autoClearColour)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | autoClearColour | To clear or not to clear |
SetMainWindowRenderTargetAutoClearDepth(Boolean)
Modify whether the framework clears the main window render target depth at the start of each draw frame
Declaration
void SetMainWindowRenderTargetAutoClearDepth(bool autoClearDepth)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | autoClearDepth | To clear or not to clear |