Ctrl+K

IGraphicsContext

Declaration

public interface Strawberry.Graphics.IGraphicsContext

Represents a graphics context used for rendering.

Implements: Strawberry.IBase

Properties

ActiveViewport abstract

The current viewport used for rendering

Viewport ActiveViewport { get }

PixelTexture abstract

Represents a single pixel with white color. You can use it to draw rectangles, lines, etc.

Texture PixelTexture { get }

ActiveRenderTarget abstract

Gets the currently active render target.

RenderTarget ActiveRenderTarget { get }

Methods

Initialize abstract

Initializes the graphics context for rendering.

void Initialize(object source, int width, int height, bool fullscreen)

Parameters:

Name Type Description
source System.Object The source to render on (It can be a window handle or a GameWindow object for OpenTK)
width System.Int32 The width of the rendering area
height System.Int32 The height of the rendering area
fullscreen System.Boolean If true the resolution of the screen will be changed.

BeginRender abstract

Starts the rendering process

void BeginRender()

Clear abstract

Cleares the screen to the specified color.

void Clear(float r, float g, float b, float a)

Parameters:

Name Type Description
r System.Single The amount of red (between 0.0 to 1.0)
g System.Single The amount of green (between 0.0 to 1.0)
b System.Single The amount of blue (between 0.0 to 1.0)
a System.Single The amount of transparency (between 0.0 to 1.0, 1.0 = opaque 0.0 = completly transparent)

Clear abstract

Cleares the screen to the specified color.

void Clear(Color color)

Parameters:

Name Type Description
color Strawberry.Graphics.Color Color

EndRender abstract

Finalizes the rendering process.

void EndRender()

AddBlendMode abstract

Adds a new blending mode to the graphics context.

void AddBlendMode(BlendMode mode, string name)

Parameters:

Name Type Description
mode Strawberry.Graphics.BlendMode The blend mode to use
name System.String The name of the added blend mode

ActivateBlendMode abstract

Activates a blend mode for rendering

void ActivateBlendMode(string name)

Parameters:

Name Type Description
name System.String The name by which the blend mode is added. (See AddBlendMode)

SetViewport abstract

Activates a viewport for rendering

void SetViewport(Viewport viewport)

Parameters:

Name Type Description
viewport Strawberry.Graphics.Viewport The viewport

ActivateRenderTarget abstract

Activates renderTarget to be used for rendering.

void ActivateRenderTarget(RenderTarget renderTarget)

Parameters:

Name Type Description
renderTarget Strawberry.Graphics.RenderTarget The render target object. If null will switch to default render target.

IsApplicationIdle abstract

bool IsApplicationIdle()

CreateTexture abstract

Creates a texture using an array of colors

Texture CreateTexture(int width, int height, Color[] data, TextureFormat format = 0)

Parameters:

Name Type Description
width System.Int32 The width of the texture
height System.Int32 The height of the texture
data Strawberry.Graphics.Color[] The color data (This data depends on Texture format)
format Strawberry.Graphics.TextureFormat = 0 The format the texture will use

Returns: The texture object

CreateTexture abstract

Creates a texture using an array of bytes

Texture CreateTexture(int width, int height, byte[] data, TextureFormat format = 0)

Parameters:

Name Type Description
width System.Int32 The width of the texture
height System.Int32 The height of the texture
data System.Byte[] The color data (This data depends on Texture format)
format Strawberry.Graphics.TextureFormat = 0 The format the texture will use

CreateTexture abstract

Texture CreateTexture(int width, int height, byte[] data, TextureSettings settings)

Parameters:

Name Type Description
width System.Int32
height System.Int32
data System.Byte[]
settings Strawberry.Graphics.TextureSettings

CreateTexture abstract

Texture CreateTexture(int width, int height, Color[] data, TextureSettings settings)

Parameters:

Name Type Description
width System.Int32
height System.Int32
data Strawberry.Graphics.Color[]
settings Strawberry.Graphics.TextureSettings

CreateShader abstract

Creates a shader using vertex and pixel shaders passed to it

Shader CreateShader(string vsCode, string psCode, string vsEntryPoint, string psEntryPoint, VertexElementContainer elements)

Parameters:

Name Type Description
vsCode System.String The vertex shader code
psCode System.String The pixel shader code
vsEntryPoint System.String The vertex shader main function
psEntryPoint System.String The pixel shader main function
elements Strawberry.Graphics.VertexElementContainer The elements to be passed to the shader like positions, colors, normals, etc

CreateGeometry abstract

Creates a geometry using specified vertext type.

Geometry<T> CreateGeometry<T>(T[] vertices, uint[] indices, GeometryType vbType, GeometryType ibType)

Parameters:

Name Type Description
vertices T[] An array of vertices
indices System.UInt32[] An array of indices used to join vertices and make geometries
vbType Strawberry.Graphics.GeometryType Type of vertex buffer (Dynamic or Static)
ibType Strawberry.Graphics.GeometryType Type of index buffer (Dynamic or Static)

Type Parameters:

  • T — The vertex type to be used, The data in the vertex should match VertexElementContainer used by shader

CreateRenderTarget abstract

Creates a render target. It can be used for render to texture, etc.

RenderTarget CreateRenderTarget(int width, int height)

Parameters:

Name Type Description
width System.Int32 Width of the render target
height System.Int32 Height of the render target

CreateRenderTarget abstract

RenderTarget CreateRenderTarget(Vector2 size)

Parameters:

Name Type Description
size Strawberry.Math.Vector2

Resize abstract

Resizes the main render target used by the graphics context

void Resize(int width, int height)

Parameters:

Name Type Description
width System.Int32 New width
height System.Int32 New height

GetScreenSize abstract

Vector2 GetScreenSize()