@@ -23,8 +23,8 @@ namespace BabylonNative
23
23
namespace
24
24
{
25
25
Dispatcher g_inlineDispatcher{ [](const std::function<void ()>& func) { func (); } };
26
- std::unique_ptr <Babylon::Graphics::Device> g_graphics {};
27
- std::unique_ptr <Babylon::Graphics::DeviceUpdate> g_update{};
26
+ std::optional <Babylon::Graphics::Device> g_graphicsDevice {};
27
+ std::optional <Babylon::Graphics::DeviceUpdate> g_update{};
28
28
std::unique_ptr<Babylon::Polyfills::Canvas> g_nativeCanvas{};
29
29
}
30
30
@@ -75,34 +75,34 @@ namespace BabylonNative
75
75
76
76
void UpdateView (WindowType window, size_t width, size_t height)
77
77
{
78
- m_windowConfig .Window = window;
79
- m_windowConfig .Width = width;
80
- m_windowConfig .Height = height;
78
+ m_graphicsConfig .Window = window;
79
+ m_graphicsConfig .Width = width;
80
+ m_graphicsConfig .Height = height;
81
81
UpdateGraphicsConfiguration ();
82
82
}
83
83
84
84
void UpdateGraphicsConfiguration ()
85
85
{
86
- if (!g_graphics )
86
+ if (!g_graphicsDevice )
87
87
{
88
- g_graphics = Babylon::Graphics::Device::Create (m_windowConfig );
89
- g_update = std::make_unique<Babylon::Graphics::DeviceUpdate>(g_graphics ->GetUpdate (" update" ));
88
+ g_graphicsDevice. emplace (m_graphicsConfig );
89
+ g_update. emplace (g_graphicsDevice ->GetUpdate (" update" ));
90
90
}
91
91
else
92
92
{
93
- g_graphics ->UpdateWindow (m_windowConfig );
94
- g_graphics ->UpdateSize (m_windowConfig .Width , m_windowConfig .Height );
93
+ g_graphicsDevice ->UpdateWindow (m_graphicsConfig. Window );
94
+ g_graphicsDevice ->UpdateSize (m_graphicsConfig .Width , m_graphicsConfig .Height );
95
95
}
96
- g_graphics ->UpdateMSAA (mMSAAValue );
97
- g_graphics ->UpdateAlphaPremultiplied (mAlphaPremultiplied );
96
+ g_graphicsDevice ->UpdateMSAA (mMSAAValue );
97
+ g_graphicsDevice ->UpdateAlphaPremultiplied (mAlphaPremultiplied );
98
98
99
- g_graphics ->EnableRendering ();
99
+ g_graphicsDevice ->EnableRendering ();
100
100
101
101
std::call_once (m_isGraphicsInitialized, [this ]()
102
102
{
103
103
m_jsDispatcher ([this ]()
104
104
{
105
- g_graphics ->AddToJavaScript (m_env);
105
+ g_graphicsDevice ->AddToJavaScript (m_env);
106
106
Babylon::Plugins::NativeEngine::Initialize (m_env);
107
107
});
108
108
});
@@ -121,18 +121,18 @@ namespace BabylonNative
121
121
void UpdateMSAA (uint8_t value)
122
122
{
123
123
mMSAAValue = value;
124
- if (g_graphics )
124
+ if (g_graphicsDevice )
125
125
{
126
- g_graphics ->UpdateMSAA (value);
126
+ g_graphicsDevice ->UpdateMSAA (value);
127
127
}
128
128
}
129
129
130
130
void UpdateAlphaPremultiplied (bool enabled)
131
131
{
132
132
mAlphaPremultiplied = enabled;
133
- if (g_graphics )
133
+ if (g_graphicsDevice )
134
134
{
135
- g_graphics ->UpdateAlphaPremultiplied (enabled);
135
+ g_graphicsDevice ->UpdateAlphaPremultiplied (enabled);
136
136
}
137
137
}
138
138
@@ -144,12 +144,12 @@ namespace BabylonNative
144
144
}
145
145
// If rendering has not been explicitly enabled, or has been explicitly disabled, then don't try to render.
146
146
// Otherwise rendering can be implicitly enabled, which may not be desirable (e.g. after the engine is disposed).
147
- if (g_graphics && m_isRenderingEnabled)
147
+ if (g_graphicsDevice && m_isRenderingEnabled)
148
148
{
149
- g_graphics ->StartRenderingCurrentFrame ();
149
+ g_graphicsDevice ->StartRenderingCurrentFrame ();
150
150
g_update->Start ();
151
151
g_update->Finish ();
152
- g_graphics ->FinishRenderingCurrentFrame ();
152
+ g_graphicsDevice ->FinishRenderingCurrentFrame ();
153
153
}
154
154
}
155
155
@@ -160,10 +160,10 @@ namespace BabylonNative
160
160
161
161
void ResetView ()
162
162
{
163
- if (g_graphics )
163
+ if (g_graphicsDevice )
164
164
{
165
165
g_nativeCanvas->FlushGraphicResources ();
166
- g_graphics ->DisableRendering ();
166
+ g_graphicsDevice ->DisableRendering ();
167
167
}
168
168
169
169
m_isRenderingEnabled = false ;
@@ -264,7 +264,7 @@ namespace BabylonNative
264
264
Babylon::Plugins::NativeInput* m_nativeInput{};
265
265
std::optional<Babylon::Plugins::NativeXr> m_nativeXr{};
266
266
267
- Babylon::Graphics::WindowConfiguration m_windowConfig {};
267
+ Babylon::Graphics::Configuration m_graphicsConfig {};
268
268
269
269
std::shared_ptr<bool > m_isXRActive{};
270
270
uint8_t mMSAAValue {};
0 commit comments