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
Implements
Inherited Members
Namespace: ImGuiScene
Assembly: ImGuiScene.dll
Syntax
public class SimpleImGuiScene : IDisposable
Constructors
| Improve this Doc View SourceSimpleImGuiScene(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 SourceOnBuildUI
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 SourceFramerateLimit
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 |
ImGuiIniPath
Declaration
public string ImGuiIniPath { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
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 |
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 |
Renderer
The renderer backend being used to render into this window.
Declaration
public IRenderer Renderer { get; }
Property Value
| Type | Description |
|---|---|
| IRenderer |
ShouldQuit
Whether the user application has requested the system to terminate.
Declaration
public bool ShouldQuit { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
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 SourceCreateOverlay(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. |
| SDL2.SDL.SDL_Scancode | closeOverlayKey | Which SDL2.SDL.SDL_Scancode to listen for in order to exit the scene. Defaults to SDL2.SDL.SDL_Scancode.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 |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
Finalize()
Declaration
protected void Finalize()
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.
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.
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 |
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()
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()