-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathCSessionWindow.h
More file actions
117 lines (92 loc) · 3.02 KB
/
CSessionWindow.h
File metadata and controls
117 lines (92 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (C) 2025-2026 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_THIS_EXAMPLE_C_SESSION_WINDOW_H_INCLUDED_
#define _NBL_THIS_EXAMPLE_C_SESSION_WINDOW_H_INCLUDED_
#include "imgui.h"
#include "renderer/shaders/pathtrace/push_constants.hlsl"
#include <functional>
#include <string>
#include <array>
#include <renderer/CSession.h>
namespace nbl::this_example
{
class CSession;
}
namespace nbl::this_example::gui
{
class CSessionWindow final
{
public:
// Buffer types that can be displayed
enum class BufferType : uint32_t
{
Beauty = 0,
Albedo,
Normal,
Motion,
Mask,
RWMCCascades,
SampleCount,
Count
};
// Callbacks to main app
struct SCallbacks
{
// Requires session recreation
std::function<void(CSession::RenderMode mode, CSession* session)> onRenderModeChanged = nullptr;
std::function<void(uint16_t width, uint16_t height)> onResolutionChanged = nullptr;
// Requires reset()
std::function<void(const SSensorDynamics& dynamics, CSession* session)> onMutablesChanged = nullptr;
// Immediate update()
std::function<void(const SSensorDynamics& dynamics, CSession* session)> onDynamicsChanged = nullptr;
// Buffer view change
std::function<void(int bufferIndex)> onBufferSelected = nullptr;
};
void setCallbacks(const SCallbacks& callbacks) { m_callbacks = callbacks; }
CSessionWindow() = default;
~CSessionWindow() = default;
// Set active session to display/control
void setSession(CSession* session);
// Set texture IDs for buffer thumbnails (called by CUIManager)
void setBufferTextureIDs(const std::array<uint32_t, static_cast<size_t>(BufferType::Count)>& textureIDs);
// forceReposition: if true, window will reposition to default location
void draw(bool forceReposition = false);
bool isOpen() const { return m_isOpen; }
void setOpen(bool open) { m_isOpen = open; }
// Get currently selected buffer
BufferType getSelectedBuffer() const { return static_cast<BufferType>(m_state.selectedBufferIndex); }
private:
CSession* m_session = nullptr;
bool m_isOpen = true;
SCallbacks m_callbacks;
// Texture IDs for buffer thumbnails
std::array<uint32_t, static_cast<size_t>(BufferType::Count)> m_bufferTextureIDs = {};
// Local state for UI controls
struct SState
{
// Mode
CSession::RenderMode renderMode = CSession::RenderMode::Beauty;
// Dynamics
float cropOffsetX = 0.0f;
float cropOffsetY = 0.0f;
float tMax = 10000.0f;
// Mutables
int cropWidth = 1920;
int cropHeight = 1080;
float nearClip = 0.1f;
float farClip = 10000.0f;
// View
int selectedBufferIndex = 0;
} m_state;
// Copies to check for changes
SSensorDynamics m_cachedDynamics;
void drawRenderModeSection();
void drawDynamicsSection();
void drawMutablesSection();
void drawOutputBufferSection();
// Get buffer name for display
static const char* getBufferName(BufferType type);
};
} // namespace nbl::this_example::gui
#endif // _NBL_THIS_EXAMPLE_C_SESSION_WINDOW_H_INCLUDED_