Foundation
Loading...
Searching...
No Matches
Public Attributes | Private Member Functions | Private Attributes | List of all members
ModelViewer::App Class Reference

Model Viewer Application implementation. More...

#include <App.hpp>

Inheritance diagram for ModelViewer::App:
Foundation::Rendering::RenderApplication Foundation::Native::NativeApplication

Public Attributes

const RHIExtent3D kTextureMaxExtent { 4096, 4096, 1 }
 
RHIExtent3D mViewportSize { 1280, 720, 1 }
 
UniquePtr< ScenemScene
 
UniquePtr< GPUScenemGPUScene
 

Private Member Functions

void OnImGui ()
 
void OnDeviceSetup () override
 Actions to take after device specific resources has been set up.
 
void OnRendererSetup () override
 Set up the renderer by creating passes, resources, and other configurations.
 
void OnApplicationTick () override
 Action to take on every application tick.
 
void OnBeforeFrame () override
 Action to take before each frame is executed.
 
void OnRendererPostSetup () override
 Action to take after the renderer has been set up.
 

Private Attributes

ResourceHandle mGBufferSRV { kInvalidHandle }
 
ImTextureID mGBufferHandle {}
 

Additional Inherited Members

- Public Member Functions inherited from Foundation::Rendering::RenderApplication
template<typename Backend , typename... Args>
void Initialize (ApplicationInitDesc const &desc={}, Args &&... args)
 Initialize the application with the specified RHI backend.
 
RHIExtent2D GetFramebufferSize () const
 Retrieve the framebuffer size of the current window.
 
FrameTiming GetTiming () const
 Retrieve the timing information of the last frame.
 
RendererGetRenderer () const
 Retrieve the underlying Renderer instance.
 
RHISwapchainGetSwapchain () const
 Retrieve the current RHISwapchain instance.
 
Native::NativeWindowGetNativeWindow ()
 Retrieve the current NativeWindow instance.
 
AllocatorGetAllocator ()
 Retrieve the allocator used for general application allocations.
 
AllocatorGetRendererAllocator ()
 Retrieve the allocator used for renderer allocations.
 
void RunForever ()
 Start the Render thread and run the application loop indefinitely, until the window is closed or the application is exited.
 
void WaitForFrame ()
 Wait for the render thread to start, or the next frame to be rendered.
 
void ResetRendererOnNextFrame ()
 Reset the renderer on the next frame, calling OnRendererSetup internally.
 
void Shutdown ()
 Flag the application to exit.
 
- Public Member Functions inherited from Foundation::Native::NativeApplication
template<typename T = float>
T GetApplicationTime () const
 Returns a high-resolution time in seconds since the application started.
 
size_t GetApplicationCounter () const
 Returns a high-resolution time in nanoseconds since the application started.
 
 NativeApplication ()
 
virtual ~NativeApplication ()
 
- Static Public Member Functions inherited from Foundation::Native::NativeApplication
static NativeWindow CreateNativeWindow (uint32_t width, uint32_t height, const char *title)
 Creates a window with the specified width, height, and title.
 
- Protected Member Functions inherited from Foundation::Rendering::RenderApplication
virtual void OnAfterFrame ()
 Action to take after each frame is executed.
 
- Protected Attributes inherited from Foundation::Rendering::RenderApplication
ApplicationInitDesc mDesc
 
DefaultAllocator mAlloc
 
DefaultAllocator mAllocRenderer
 
Native::NativeWindow mWindow
 
UniquePtr< RHIApplicationmRHI
 
RHIApplicationScopedObjectHandle< RHIDevicemDevice
 
RHIDeviceScopedObjectHandle< RHISwapchainmSwapchain
 
UniquePtr< RenderermRenderer
 
FrameTiming mTiming {}
 
Async::Thread mRenderThread
 
Async::Condition mRenderFrame
 
Async::Mutex mRenderMutex
 
bool mRenderThreadReset {false}
 
bool mRenderThreadStarted {false}
 
bool mAppShouldClose {false}
 

Detailed Description

Model Viewer Application implementation.

Member Function Documentation

◆ OnApplicationTick()

void ModelViewer::App::OnApplicationTick ( )
overrideprivatevirtual

Action to take on every application tick.

Note
This is run on the main thread, i.e. the calling thread of RunForever. No synchronization is performed on a per-frame basis. You may want to use WaitForFrame() to synchronize with the render thread if needed.
This runs in a tight loop in RunForever(), and is only run after the Render thread has started - i.e. after OnDeviceSetup() and OnRendererSetup() has been called, in that order.

Implementation may leave this empty if no action is needed.

Note
This should not be directly called.

Reimplemented from Foundation::Rendering::RenderApplication.

◆ OnBeforeFrame()

void ModelViewer::App::OnBeforeFrame ( )
overrideprivatevirtual

Action to take before each frame is executed.

This is run on the Render thread.

This is invoked before the renderer executes the passes, but after the current frame is acquired from the swapchain.

Implementation may leave this empty if no action is needed.

Note
This should not be directly called.

Reimplemented from Foundation::Rendering::RenderApplication.

◆ OnDeviceSetup()

void ModelViewer::App::OnDeviceSetup ( )
overrideprivatevirtual

Actions to take after device specific resources has been set up.

This is run on the main thread, i.e. the calling thread of Initialize(), after the device and swapchain is created, but before the Renderer is created.

Implementation may leave this empty if no action is needed.

Note
This should not be directly called.

Reimplemented from Foundation::Rendering::RenderApplication.

◆ OnImGui()

void ModelViewer::App::OnImGui ( )
private

◆ OnRendererPostSetup()

void ModelViewer::App::OnRendererPostSetup ( )
overrideprivatevirtual

Action to take after the renderer has been set up.

This is run on the Render thread, immediately after OnRendererSetup has been called, and before the first frame is rendered.

Implementation may leave this empty if no action is needed.

Note
This should not be directly called.

Reimplemented from Foundation::Rendering::RenderApplication.

◆ OnRendererSetup()

void App::OnRendererSetup ( )
overrideprivatevirtual

Set up the renderer by creating passes, resources, and other configurations.

Note
This is where you should set up your rendering pipeline.
This is invoked by InitializeRenderer on the Render thread, within a Renderer::BeginSetup and Renderer::EndSetup clause, thus invoking Renderer::BeginSetup, Renderer::EndSetup here again is incorrect. and will be called again if the swapchain is recreated.
This MUST be implemented by the subclass.
This should not be directly called.

Implements Foundation::Rendering::RenderApplication.

Member Data Documentation

◆ kTextureMaxExtent

const RHIExtent3D ModelViewer::App::kTextureMaxExtent { 4096, 4096, 1 }

◆ mGBufferHandle

ImTextureID ModelViewer::App::mGBufferHandle {}
private

◆ mGBufferSRV

ResourceHandle ModelViewer::App::mGBufferSRV { kInvalidHandle }
private

◆ mGPUScene

UniquePtr<GPUScene> ModelViewer::App::mGPUScene

◆ mScene

UniquePtr<Scene> ModelViewer::App::mScene

◆ mViewportSize

RHIExtent3D ModelViewer::App::mViewportSize { 1280, 720, 1 }

The documentation for this class was generated from the following files: