IGraphicsContextFactory

Description

interface Tinman.Engine.Rendering.IGraphicsContextFactory

Base interface for classes that create IGraphicsContext instances.

An implementation class of the IGraphicsContextFactory interface can always be used, even if the underlying graphics API is not supported or if the required 3rd-party .NET assemblies have been omitted from the binary distribution. In any of these cases, the CanCreateGraphicsContext property will return false. In the latter case, using an implementation class of the IGraphicsContext interface can cause runtime exceptions, for example System.TypeInitializationException and System.IO.FileNotFoundException. Use the IGraphicsContext.IsCompatibleWith method to find out whether a context object is compatible with a supported factory.

Public / Methods

Get​Graphics​Context


[OwnerReturn]
public method GetGraphicsContext → ()

returns → IGraphicsContext

The graphics context.

Returns the graphics context for the current factory settings.

IOException

If an I/O error has occurred while loading the shader effects (see ShaderRepository).

RenderException

If CanCreateGraphicsContext returns false or if the graphics driver has returned an error.

Public / Attributes

Adapter​Names


[Constant]
public attribute AdapterNames → (get)

value : IVectorConst<string>

[not-null]
The list of human-readable graphics adapter names.

Returns the human-readable names of the graphics adapters.

A graphics adapter name always has the following form:

#n: ...

where n is the zero-based adapter ordinal and …​ is the adapter name.

Adapter​Ordinal


public attribute AdapterOrdinal → (get,set)

value : int32

The graphics adapter ordinal. If negative or greater than or equal to IBagConst.Count of AdapterNames, CanCreateGraphicsContext will always return false and GetGraphicsContext will always throw a RenderException.

Chooses the graphics adapter.

Defaults to 0.

Available​Video​Memory


public attribute AvailableVideoMemory → (get,set)

value : int32

[>=0]
The estimated total amount of GPU memory (dedicated), in megabytes. If 0, the memory amount will be determined automatically. If this is not possible, the memory amount will be set to 2048.

The estimated total amount of GPU memory.

The default value is 0.

Can​Create​Graphics​Context


[Constant]
public attribute CanCreateGraphicsContext → (get)

value : bool

true if the graphics context is available, false if not.

Can this factory create a graphics context in the current environment?

The value of this property reflects the environment only, e.g. the availability and feature level of native libraries. It does not take into account the current application state, such as the presence of a primary window.

Maximum​Texture​Size


public attribute MaximumTextureSize → (get,set)

value : int32

[>=0]
The maximum memory size, in megabytes. If 0, the maximum size will be determined automatically. If this is not possible, the maximum size will be set to 2048.

The maximum size of a single texture resource in video memory.

The default value is 0.

Multi​Sampling


public attribute MultiSampling → (get,set)

value : MultiSampleType

The multisampling type.

The multisampling type to use.

If the given multisampling type is not supported, the closest match will be used.

The default value is MultiSampleType.None.

Name


[Constant]
public attribute Name → (get)

value : string

[not-empty]
The graphics context factory name.

Human-readable name of this graphics context factory.

Shader​Repository


public attribute ShaderRepository → (get,set)

value : Path

[not-null]
The public GPU shader repository path or Path.Unknown to disable the public repository.

Path to the base directory of the public GPU shader repository.

A shader repository is structured like this:

path/lang.api/

where path is the ShaderRepository, lang is the name of the shader programming language (e.g. glsl, hlsl) and api is the name tag of the graphics API (e.g. dx9, dx11, dx12, gl41, gles30). Usually, there will be some shared code in this directory:

path/lang/

The contents of the directory for a specific shader programming language and graphics API is defined by the corresponding IGraphicsContextFactory implementation. An implementation may have a private GPU shader repository, specified by a mechanism that is defined by the implementation (for example, an embedded ZIP resource or a separate local directory).

When the IRenderEffectFactory.CreateRenderEffect method needs to load a GPU shader, it first checks whether the shader files are present in the public GPU shader repository or not. Only if the public repository is disabled or if the shader file are not present, the factory method falls back to the private GPU shader repository. If the IRenderEffectFactory implementation does not have a private repository, render effect creation will fail.

Defaults to Path.Unknown.

Vertical​Sync


public attribute VerticalSync → (get,set)

value : bool

true to enable vertical sync, false to disable it.

Enable vertical sync, if possible?

The default value is true.