|
TachyonUI 0.1.0
High-performance UI for building tools.
|
A graphics backend: the device, the window contexts that render the GUI's windows, and the images and text atlases they draw with. More...
#include <gui_core/graphics/gui_graphics_context.h>
Public Member Functions | |
| GraphicsContext ()=default | |
| virtual | ~GraphicsContext () |
| virtual GraphicsAPI | GetAPI () const =0 |
| The API it presents with; window backends make their windows for it. | |
| virtual void | SetAllocationHooks (const AllocationHooks &hooks)=0 |
| Host memory functions for the graphics API's allocations. Call before Initialize. | |
| virtual Result< void > | Initialize (IWindowBackend *windowBackend)=0 |
| Brings the device up; GUIApplication::Initialize calls it once, before any window context. | |
| virtual bool | DeviceLost () const |
| True once the GPU device is lost; RecreateDevice then makes a new one. | |
| virtual Result< void > | RecreateDevice (IWindowBackend *) |
| Makes a new device after DeviceLost, and everything the backend owns on it (the window contexts are the caller's to make again). | |
| virtual void | Cleanup ()=0 |
| Waits for the GPU and destroys what the backend made, the renderer included. | |
| virtual void | BeginFrame ()=0 |
| Starts a frame's UI build: resets the renderer for new primitives (Vulkan: also frees what frame-scoped deletions held long enough). | |
| virtual void | EndFrame ()=0 |
| Ends the UI build, before the uploads and the window contexts' recording. | |
| virtual Image * | CreateImage (void *data, uint2 size, ImageFormat format, Sampler sampler, bool mipmapped=false)=0 |
| Makes an image from size.x x size.y tightly packed pixels of format (Vulkan: data null for a cleared image); mipmapped generates its mip levels. | |
| virtual void | DestroyImageAtEnd (Image *img, DeviceScope scope, const std::source_location &loc=std::source_location::current())=0 |
| Destroys the image and deletes the object once the GPU is done with it: a few frames on for DeviceScope::Frame, at Cleanup for DeviceScope::Application. | |
| virtual TextAtlasManager * | CreateTextAtlasManager ()=0 |
| A new text atlas manager for the backend. The caller owns it and keeps it past Cleanup. | |
| virtual IWindowContext * | CreateWindowContext (void *nativeWindowHandle, OSWindowHandle osHandle, ID id, int2 size, WindowFlags windowFlags, OnGuiFunc onGui)=0 |
| Makes the context that renders an OS window: nativeWindowHandle comes from IWindowBackend::GetNativeHandle, size is in pixels and onGui builds the window's UI. | |
| virtual void | DestroyWindowContext (IWindowContext *context)=0 |
| Waits for the context's GPU work and destroys it now; its native window must still exist. | |
| virtual ImageSet * | GetImageSet () const =0 |
| The images the shaders sample, by ImageIndex. | |
| virtual ImageIndex | RegisterImage (Image *image)=0 |
| Adds the image to the image set; elements draw it by the returned index. | |
| virtual void | UnregisterImage (ImageIndex index)=0 |
| Frees the index for reuse; the image stays (DestroyImageAtEnd destroys it). | |
| virtual void | PrepareFrame (StyleManager &styleManager, GradientManager &gradientManager, float elapsedTimeSecs)=0 |
| Uploads the styles and gradient pages for this frame's draws, after the UI build and before the window contexts record. | |
| virtual float | GetLastFrameBuildSeconds () const |
| Wall-clock seconds of CPU work in the last frame: from just after one present returns to just before the next, so without the vsync wait. | |
Public Attributes | |
| GUIRenderer * | guiRenderer = nullptr |
| Where the UI records its draw primitives. | |
A graphics backend: the device, the window contexts that render the GUI's windows, and the images and text atlases they draw with.
GUIApplication::SetGraphicsBackend sets one; VulkanGraphicsContext is the default, NullGraphicsContext draws nothing.
|
default |
|
inlinevirtual |
|
pure virtual |
The API it presents with; window backends make their windows for it.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Host memory functions for the graphics API's allocations. Call before Initialize.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Brings the device up; GUIApplication::Initialize calls it once, before any window context.
It may make windows with the backend (Vulkan: a hidden one, to pick a GPU that can present to it).
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
inlinevirtual |
True once the GPU device is lost; RecreateDevice then makes a new one.
Reimplemented in tachyon::vulkan::VulkanGraphicsContext.
|
inlinevirtual |
Makes a new device after DeviceLost, and everything the backend owns on it (the window contexts are the caller's to make again).
The default fails with ErrorCode::Unsupported.
Reimplemented in tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Waits for the GPU and destroys what the backend made, the renderer included.
The window contexts are destroyed before it.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Starts a frame's UI build: resets the renderer for new primitives (Vulkan: also frees what frame-scoped deletions held long enough).
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Ends the UI build, before the uploads and the window contexts' recording.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Makes an image from size.x x size.y tightly packed pixels of format (Vulkan: data null for a cleared image); mipmapped generates its mip levels.
Doesn't wait for the GPU: the upload goes with the next frame. RegisterImage makes it drawable.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Destroys the image and deletes the object once the GPU is done with it: a few frames on for DeviceScope::Frame, at Cleanup for DeviceScope::Application.
loc is for diagnostics.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
A new text atlas manager for the backend. The caller owns it and keeps it past Cleanup.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Makes the context that renders an OS window: nativeWindowHandle comes from IWindowBackend::GetNativeHandle, size is in pixels and onGui builds the window's UI.
nullptr on failure. Destroy it with DestroyWindowContext.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Waits for the context's GPU work and destroys it now; its native window must still exist.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
The images the shaders sample, by ImageIndex.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Adds the image to the image set; elements draw it by the returned index.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Frees the index for reuse; the image stays (DestroyImageAtEnd destroys it).
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
pure virtual |
Uploads the styles and gradient pages for this frame's draws, after the UI build and before the window contexts record.
elapsedTimeSecs: the frame clock's time, for shader animation.
Implemented in tachyon::NullGraphicsContext, and tachyon::vulkan::VulkanGraphicsContext.
|
inlinevirtual |
Wall-clock seconds of CPU work in the last frame: from just after one present returns to just before the next, so without the vsync wait.
0 for backends that don't measure it.
Reimplemented in tachyon::vulkan::VulkanGraphicsContext.
| GUIRenderer* tachyon::GraphicsContext::guiRenderer = nullptr |
Where the UI records its draw primitives.
Owned by the context: made in its constructor, deleted by Cleanup.