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.
Assembly: ImGuiScene.dll
View Source
public class SimpleImGuiScene : IDisposable
Implements:
System.IDisposable
Properties
Window
The main application container window where we do all our rendering and input processing.
View Source
public SimpleSDLWindow Window { get; }
Renderer
The renderer backend being used to render into this window.
View Source
public IRenderer Renderer { get; }
ShouldQuit
Whether the user application has requested the system to terminate.
View Source
public bool ShouldQuit { get; set; }
FramerateLimit
The method of framerate control used by the scene and renderer. The default behavior is ImGuiScene.FramerateLimit.LimitType.Vsync, which is greatly recommended unless you have a specific need to change it.
View Source
public FramerateLimit FramerateLimit { get; set; }
ImGuiIniPath
View Source
public string ImGuiIniPath { get; set; }
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.
View Source
public bool PauseWhenUnfocused { get; set; }
OnSDLEvent
Delegate for providing user event handler methods that want to respond to SDL_Events. This is just a convenience wrapper around ImGuiScene.SimpleSDLWindow.OnSDLEvent.
View Source
public SimpleSDLWindow.ProcessEventDelegate OnSDLEvent { get; set; }
Fields
OnBuildUI
User methods invoked every ImGui frame to construct custom UIs.
View Source
public SimpleImGuiScene.BuildUIDelegate OnBuildUI
Methods
CreateOverlay(RendererBackend, SDL_Scancode, float[], bool)
Helper method to create a fullscreen transparent overlay that exits when pressing the specified key.
View Source
public static SimpleImGuiScene CreateOverlay(RendererFactory.RendererBackend rendererBackend, SDL.SDL_Scancode closeOverlayKey = SDL_Scancode.SDL_SCANCODE_ESCAPE, float[] transparentColor = null, bool enableRenderDebugging = false)
Returns
Parameters
Type | Name | Description |
---|---|---|
ImGuiScene.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. |
LoadImage(string)
Loads an image from a file and creates the corresponding GPU texture.
View Source
public TextureWrap LoadImage(string path)
Returns
ImGuiScene.TextureWrap: A ImGuiScene.TextureWrap associated with the loaded texture resource, containing a handle suitable for direct use in ImGui, or null on failure.
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The filepath to the image |
LoadImage(byte[])
Loads an image from a byte array of image data and creates the corresponding texture resource.
View Source
public TextureWrap LoadImage(byte[] imageBytes)
Returns
ImGuiScene.TextureWrap: A ImGuiScene.TextureWrap associated with the loaded texture resource, containing a handle suitable for direct use in ImGui, or null on failure.
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | imageBytes | The raw image data |
LoadImageRaw(byte[], int, int, int)
View Source
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels = 4)
Returns
Parameters
Type | Name |
---|---|
System.Byte[] | imageData |
System.Int32 | width |
System.Int32 | height |
System.Int32 | numChannels |
Update()
Performs a single-frame update of ImGui and renders it to the window. This method does not check any quit conditions.
View Source
public void Update()
Run()
Simple method to run the scene in a loop until the window is closed or the application requests an exit (via ImGuiScene.SimpleImGuiScene.ShouldQuit)
View Source
public void Run()
Dispose(bool)
View Source
protected virtual void Dispose(bool disposing)
Parameters
Type | Name |
---|---|
System.Boolean | disposing |
~SimpleImGuiScene()
View Source
protected ~SimpleImGuiScene()
Dispose()
View Source
public void Dispose()
Implements
System.IDisposable