Show / Hide Table of Contents

# Class SimpleImGuiScene

Simple class to wrap everything necessary to use ImGui inside a window. Currently this always creates a new window rather than take ownership of an existing one.

Internally this uses SDL and DirectX 11 or OpenGL 3.2. Rendering is tied to vsync.

##### Inheritance

System.Object
SimpleImGuiScene

##### Implements

System.IDisposable

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: ImGuiScene

###### Assembly: ImGuiScene.dll

##### Syntax

    public class SimpleImGuiScene : IDisposable

### Constructors

| Improve this Doc View Source

#### SimpleImGuiScene(RendererFactory.RendererBackend, WindowCreateInfo, Boolean)

Creates a new window and a new renderer of the specified type, and initializes ImGUI.

##### Declaration

    public SimpleImGuiScene(RendererFactory.RendererBackend rendererBackend, WindowCreateInfo createInfo, bool enableRenderDebugging = false)

##### Parameters

Type | Name | Description
--- | --- | ---
RendererFactory.RendererBackend | rendererBackend |
WindowCreateInfo | createInfo | Creation details for the window.
System.Boolean | enableRenderDebugging | Whether to enable debugging of the renderer internals. This will likely greatly impact performance and is not usually recommended.

### Fields

| Improve this Doc View Source

#### OnBuildUI

User methods invoked every ImGui frame to construct custom UIs.

##### Declaration

    public SimpleImGuiScene.BuildUIDelegate OnBuildUI

##### Field Value

Type | Description
--- | ---
SimpleImGuiScene.BuildUIDelegate |

### Properties

| Improve this Doc View Source

#### FramerateLimit

The method of framerate control used by the scene and renderer. The default behavior is Vsync, which is greatly recommended unless you have a specific need to change it.

##### Declaration

    public FramerateLimit FramerateLimit { get; set; }

##### Property Value

Type | Description
--- | ---
FramerateLimit |

| Improve this Doc View Source

#### ImGuiIniPath

##### Declaration

    public string ImGuiIniPath { get; set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### OnSDLEvent

Delegate for providing user event handler methods that want to respond to SDL_Events. This is just a convenience wrapper around OnSDLEvent.

##### Declaration

    public SimpleSDLWindow.ProcessEventDelegate OnSDLEvent { get; set; }

##### Property Value

Type | Description
--- | ---
SimpleSDLWindow.ProcessEventDelegate |

| Improve this Doc View Source

#### PauseWhenUnfocused

Whether rendering should be paused when the window is not active. Window events will still be processed. This should help reduce processing when the overlay is not the focus, but obviously cannot be used if you are rendering dynamic data.

##### Declaration

    public bool PauseWhenUnfocused { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### Renderer

The renderer backend being used to render into this window.

##### Declaration

    public IRenderer Renderer { get; }

##### Property Value

Type | Description
--- | ---
IRenderer |

| Improve this Doc View Source

#### ShouldQuit

Whether the user application has requested the system to terminate.

##### Declaration

    public bool ShouldQuit { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### Window

The main application container window where we do all our rendering and input processing.

##### Declaration

    public SimpleSDLWindow Window { get; }

##### Property Value

Type | Description
--- | ---
SimpleSDLWindow |

### Methods

| Improve this Doc View Source

#### CreateOverlay(RendererFactory.RendererBackend, SDL.SDL_Scancode, Single[], Boolean)

Helper method to create a fullscreen transparent overlay that exits when pressing the specified key.

##### Declaration

    public static SimpleImGuiScene CreateOverlay(RendererFactory.RendererBackend rendererBackend, SDL.SDL_Scancode closeOverlayKey = SDL.SDL_Scancode.SDL_SCANCODE_ESCAPE, float[] transparentColor = null, bool enableRenderDebugging = false)

##### Parameters

Type | Name | Description
--- | --- | ---
RendererFactory.RendererBackend | rendererBackend | Which rendering backend to use.
SDL.SDL_Scancode | closeOverlayKey | Which SDL.SDL_Scancode to listen for in order to exit the scene. Defaults to SDL_SCANCODE_ESCAPE.
System.Single[] | transparentColor | A float[4] representing the background window color that will be masked as transparent. Defaults to solid black.
System.Boolean | enableRenderDebugging | Whether to enable debugging of the renderer internals. This will likely greatly impact performance and is not usually recommended.

##### Returns

Type | Description
--- | ---
SimpleImGuiScene |

| Improve this Doc View Source

#### Dispose()

##### Declaration

    public void Dispose()

| Improve this Doc View Source

#### Dispose(Boolean)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | disposing |

| Improve this Doc View Source

#### Finalize()

##### Declaration

    protected void Finalize()

| Improve this Doc View Source

#### LoadImage(Byte[])

Loads an image from a byte array of image data and creates the corresponding texture resource.

##### Declaration

    public TextureWrap LoadImage(byte[] imageBytes)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | imageBytes | The raw image data

##### Returns

Type | Description
--- | ---
TextureWrap | A TextureWrap associated with the loaded texture resource, containing a handle suitable for direct use in ImGui, or null on failure.

##### Remarks

Currently any textures created by this method are managed automatically and exist until this class object is Disposed.

| Improve this Doc View Source

#### LoadImage(String)

Loads an image from a file and creates the corresponding GPU texture.

##### Declaration

    public TextureWrap LoadImage(string path)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | path | The filepath to the image

##### Returns

Type | Description
--- | ---
TextureWrap | A TextureWrap associated with the loaded texture resource, containing a handle suitable for direct use in ImGui, or null on failure.

##### Remarks

Currently any textures created by this method are managed automatically and exist until this class object is Disposed.

| Improve this Doc View Source

#### LoadImageRaw(Byte[], Int32, Int32, Int32)

##### Declaration

    public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels = 4)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | imageData |
System.Int32 | width |
System.Int32 | height |
System.Int32 | numChannels |

##### Returns

Type | Description
--- | ---
TextureWrap |

| Improve this Doc View Source

#### Run()

Simple method to run the scene in a loop until the window is closed or the application requests an exit (via ShouldQuit)

##### Declaration

    public void Run()

| Improve this Doc View Source

#### Update()

Performs a single-frame update of ImGui and renders it to the window. This method does not check any quit conditions.

##### Declaration

    public void Update()

### Implements

System.IDisposable