Skip to main content

GLFWPlatformManager Class Template

Concrete manager integrating GLFW with helios runtime/window command flow. More...

Declaration

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer> class helios::glfw::GLFWPlatformManager<TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer> { ... }

Public Member Typedefs Index

template < ... >
usingEngineRoleTag = ManagerRole

Engine role marker used by runtime registries. More...

Public Constructors Index

template < ... >
GLFWPlatformManager (TRenderPlatform &renderPlatform, PlatformWorld &platformWorld, CommandBufferRegistry &commandBufferRegistry)

Public Member Functions Index

template < ... >
voidflush (UpdateContext &updateContext) noexcept

Processes queued platform/window work for the current frame. More...

template < ... >
boolsubmit (const PollEventsCommand &command) noexcept

Marks that platform events should be polled in the next flush(...). More...

template < ... >
boolsubmit (const PlatformInitCommand &command) noexcept

Marks platform initialization for execution during the next flush(...). More...

template < ... >
boolsubmit (const WindowCreateCommand< THandle > &command) noexcept

Queues a window creation request. More...

template < ... >
boolsubmit (const SwapBuffersCommand< THandle > &command) noexcept

Queues a buffer-swap request for a specific window. More...

template < ... >
boolsubmit (const WindowResizeCommand< THandle > &command) noexcept

Stores the latest resize request per window entity index. More...

template < ... >
boolsubmit (const WindowCloseCommand< THandle > &command) noexcept

Queues a window-close request. More...

template < ... >
boolsubmit (const ShutdownCommand &command) noexcept

Marks platform shutdown for execution during the next flush(...). More...

template < ... >
voidinit (CommandHandlerRegistry &commandHandlerRegistry) noexcept

Registers this manager as handler for supported platform/window commands. More...

Private Member Functions Index

template < ... >
boolinitPlatform (UpdateContext &updateContext) noexcept

Initializes GLFW and transitions runtime/session from booting to boot request. More...

template < ... >
boolcreateWindow (UpdateContext &updateContext, const WindowCreateCommand< THandle > &cmd) noexcept

Creates a native GLFW window and binds it to the requested window entity. More...

template < ... >
voidremoveCurrentContext (UpdateContext &updateContext)

Removes CurrentContextComponent from all windows currently marked as active context. More...

template < ... >
voidinstallResizeListener (THandle handle) noexcept

Installs GLFW user-pointer data and renderTarget resize callback for a window. More...

template < ... >
voidswapBuffer (UpdateContext &updateContext, const SwapBuffersCommand< THandle > &cmd) noexcept

Executes a single swap-buffers command. More...

template < ... >
boolcreateWindows (UpdateContext &updateContext) noexcept

Creates all windows queued during command submission. More...

template < ... >
voidresizeWindows (UpdateContext &updateContext) noexcept

Applies queued resize commands to window components. More...

template < ... >
voidswapBuffers (UpdateContext &updateContext) noexcept

Processes all queued swap-buffers commands. More...

template < ... >
voidpollEvents (UpdateContext &updateContext) noexcept

Polls GLFW events if requested by a poll-events command. More...

template < ... >
voidcloseWindows (UpdateContext &updateContext) noexcept

Destroys all windows queued for closing. More...

template < ... >
voidshutdown (UpdateContext &updateContext) noexcept

Terminates GLFW and queues a shutdown state transition request. More...

Private Member Attributes Index

template < ... >
std::vector< WindowResizeCommand< THandle > >pendingResizeCommands_
template < ... >
std::vector< WindowCreateCommand< THandle > >windowCreateCommands_
template < ... >
std::vector< SwapBuffersCommand< THandle > >pendingBufferSwaps_
template < ... >
std::vector< WindowCloseCommand< THandle > >pendingCloseCommands_
template < ... >
std::vector< THandle >currentContexts_
template < ... >
boolshouldInit_ = false
template < ... >
boolshouldShutdown_ = false
template < ... >
boolpollEvents_ = false
template < ... >
boolinitialized_ = false
template < ... >
TRenderPlatform &renderPlatform_
template < ... >
PlatformWorld *platformWorld_
template < ... >
CommandBufferRegistry *commandBufferRegistry_ = nullptr

Private Static Attributes Index

template < ... >
static const helios::engine::util::log::Logger &logger_ = ...

Description

Concrete manager integrating GLFW with helios runtime/window command flow.

The manager receives runtime and window commands via submit(...), stores them as pending work, and processes them in flush(...) in a deterministic order.

Template Parameters
THandle

Window/entity handle type.

TStateCommandBuffer

Command buffer used for follow-up state commands.

TPlatformCommandBuffer

Command buffer used by GLFW callbacks for platform commands.

Definition at line 99 of file GLFWPlatformManager.ixx.

Public Member Typedefs

EngineRoleTag

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
using helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::EngineRoleTag = ManagerRole

Engine role marker used by runtime registries.

Definition at line 491 of file GLFWPlatformManager.ixx.

491 using EngineRoleTag = ManagerRole;

Public Constructors

GLFWPlatformManager()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::GLFWPlatformManager (TRenderPlatform & renderPlatform, PlatformWorld & platformWorld, CommandBufferRegistry & commandBufferRegistry)
inline explicit

Definition at line 493 of file GLFWPlatformManager.ixx.

494 TRenderPlatform& renderPlatform,
495 PlatformWorld& platformWorld,
496 CommandBufferRegistry& commandBufferRegistry)
497 : renderPlatform_(renderPlatform),
498 platformWorld_(&platformWorld),
499 commandBufferRegistry_(&commandBufferRegistry) {};

Public Member Functions

flush()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::flush (UpdateContext & updateContext)
inline noexcept

Processes queued platform/window work for the current frame.

Parameters
updateContext

Frame-local update context.

Definition at line 507 of file GLFWPlatformManager.ixx.

507 void flush(UpdateContext& updateContext) noexcept {
508
509 if (shouldShutdown_) {
510 shutdown(updateContext);
511 return;
512 }
513
514 if (initPlatform(updateContext)) {
515 commandBufferRegistry_->template item<TStateCommandBuffer>()->template add<StateCommand<EngineState>>(
516 StateTransitionRequest<EngineState>(
517 updateContext.session().state<EngineState>(),
518 EngineStateTransitionId::BootRequest
519 )
520 );
521 }
522 pollEvents(updateContext);
523 const bool isContextAvailable = createWindows(updateContext);
524
525 if (!renderPlatform_.isInitialized() && isContextAvailable) {
526 if (renderPlatform_.init()) {
527 updateContext.runtimeEnvironment().setGPUReady();
528 }
529 }
530
531 resizeWindows(updateContext);
532 closeWindows(updateContext);
533 swapBuffers(updateContext);
534 }

init()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::init (CommandHandlerRegistry & commandHandlerRegistry)
inline noexcept

Registers this manager as handler for supported platform/window commands.

Parameters
commandHandlerRegistry

Registry used for command-handler registration.

Definition at line 632 of file GLFWPlatformManager.ixx.

632 void init(CommandHandlerRegistry& commandHandlerRegistry) noexcept {
633
634 commandHandlerRegistry.handleCommands<
635 WindowCreateCommand<THandle>,
636 PlatformInitCommand,
637 WindowResizeCommand<THandle>,
638 SwapBuffersCommand<THandle>,
639 PollEventsCommand,
640 WindowCloseCommand<THandle>,
641 ShutdownCommand
642 >(*this);
643 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const PollEventsCommand & command)
inline noexcept

Marks that platform events should be polled in the next flush(...).

Parameters
command

Poll-events marker command.

Returns

true when the command was accepted.

Definition at line 543 of file GLFWPlatformManager.ixx.

543 bool submit(const PollEventsCommand& command) noexcept {
544 pollEvents_ = true;
545 return true;
546 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const PlatformInitCommand & command)
inline noexcept

Marks platform initialization for execution during the next flush(...).

Parameters
command

Platform-init marker command.

Returns

true when the command was accepted.

Definition at line 555 of file GLFWPlatformManager.ixx.

555 bool submit(const PlatformInitCommand& command) noexcept {
556 assert(!initialized_ && "Application was already initialized.");
557 shouldInit_ = true;
558 return true;
559 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const WindowCreateCommand< THandle > & command)
inline noexcept

Queues a window creation request.

Parameters
command

Window creation command.

Returns

true when the command was queued.

Definition at line 568 of file GLFWPlatformManager.ixx.

568 bool submit(const WindowCreateCommand<THandle>& command) noexcept {
569 windowCreateCommands_.push_back(command);
570 return true;
571 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const SwapBuffersCommand< THandle > & command)
inline noexcept

Queues a buffer-swap request for a specific window.

Parameters
command

Swap-buffers command.

Returns

true when the command was queued.

Definition at line 580 of file GLFWPlatformManager.ixx.

580 bool submit(const SwapBuffersCommand<THandle>& command) noexcept {
581 pendingBufferSwaps_.push_back(command);
582 return true;
583 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const WindowResizeCommand< THandle > & command)
inline noexcept

Stores the latest resize request per window entity index.

Parameters
command

Window resize command.

Returns

true when the command was stored.

Definition at line 592 of file GLFWPlatformManager.ixx.

592 bool submit(const WindowResizeCommand<THandle>& command) noexcept {
593 const auto idx = command.windowHandle.entityId;
594
595 if (pendingResizeCommands_.size() <= idx) {
596 pendingResizeCommands_.resize(idx + 1);
597 }
598
599 pendingResizeCommands_[idx] = command;
600 return true;
601 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const WindowCloseCommand< THandle > & command)
inline noexcept

Queues a window-close request.

Parameters
command

Window-close command.

Returns

true when the command was queued.

Definition at line 610 of file GLFWPlatformManager.ixx.

610 bool submit(const WindowCloseCommand<THandle>& command) noexcept {
611 pendingCloseCommands_.push_back(command);
612 return true;
613 }

submit()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::submit (const ShutdownCommand & command)
inline noexcept

Marks platform shutdown for execution during the next flush(...).

Parameters
command

Shutdown marker command.

Returns

true when the command was accepted.

Definition at line 622 of file GLFWPlatformManager.ixx.

622 bool submit(const ShutdownCommand& command) noexcept {
623 shouldShutdown_ = true;
624 return true;
625 }

Private Member Functions

closeWindows()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::closeWindows (UpdateContext & updateContext)
inline noexcept

Destroys all windows queued for closing.

Parameters
updateContext

Frame-local update context.

Definition at line 436 of file GLFWPlatformManager.ixx.

436 void closeWindows(UpdateContext& updateContext) noexcept {
437 if (pendingCloseCommands_.empty()) {
438 return;
439 }
440
441 for (const auto& cmd : pendingCloseCommands_) {
442 auto entity = updateContext.find(cmd.windowHandle);
443
444 if (!entity) {
445 logger_.warn("Entity was not found");
446 continue;
447 }
448
449 const auto* glfw = entity->template get<GLFWWindowHandleComponent<THandle>>();
450 if (!glfw) {
451 logger_.warn("Entity does not have GLFWWindowHandleComponent");
452 continue;
453 }
454
455 glfwDestroyWindow(glfw->handle);
456 bool destroyed = platformWorld_->destroy<THandle>(cmd.windowHandle);
457 assert(destroyed && "Failed to destroy entity");
458 }
459
460 pendingCloseCommands_.clear();
461 }

createWindow()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::createWindow (UpdateContext & updateContext, const WindowCreateCommand< THandle > & cmd)
inline noexcept

Creates a native GLFW window and binds it to the requested window entity.

Parameters
updateContext

Frame-local update context.

cmd

Window creation command containing target handle and config.

Returns

true if the window was created and bound successfully; otherwise false.

Definition at line 163 of file GLFWPlatformManager.ixx.

163 bool createWindow(UpdateContext& updateContext, const WindowCreateCommand<THandle>& cmd) noexcept {
164
165 auto window = updateContext.find(cmd.windowHandle);
166
167 if (!window) {
168 return false;
169 }
170
171 auto& cfg = cmd.windowConfig;
172
173 auto* nativeHandle = glfwCreateWindow(
174 cfg.size[0],
175 cfg.size[1],
176 cfg.title.c_str(),
177 nullptr,
178 nullptr
179 );
180
181 assert(nativeHandle && "Failed to create GLFW window");
182
183 if (cfg.aspectRatioNumer > 0 && cfg.aspectRatioDenom > 0) {
184 glfwSetWindowAspectRatio(
185 nativeHandle,
186 cfg.aspectRatioNumer,
187 cfg.aspectRatioDenom
188 );
189 }
190
191 assert(window->template has<WindowCreateRequestComponent<THandle>>() && "Expected entity to have WindowCreateRequestComponent");
192 window->template remove<WindowCreateRequestComponent<THandle>>();
193 assert(!window->template has<WindowCreateRequestComponent<THandle>>() && "Expected entity to not have WindowCreateRequestComponent");
194 assert(!window->template has<WindowComponent<THandle>>() && "Expected entity to not have WindowComponent");
195 window->template add<WindowComponent<THandle>>(
196 std::move(cfg.title),
197 cfg.aspectRatioNumer,
198 cfg.aspectRatioDenom
199 );
200 window->template add<
201 Size2DComponent<THandle>
202 >(WindowSize(cfg.size));
203 window->template add<GLFWWindowHandleComponent<THandle>>(nativeHandle);
204
205 removeCurrentContext(updateContext);
206
207 glfwMakeContextCurrent(nativeHandle);
208
209 window->template add<CurrentContextComponent<THandle>>();
210
211 window->template add<WindowShownComponent<THandle>>();
212 window->template add<GLFWWindowUserPointerComponent<THandle, TPlatformCommandBuffer>>(
214 cmd.windowHandle, commandBufferRegistry_->template item<TPlatformCommandBuffer>()
215 ));
216
217 installResizeListener(cmd.windowHandle);
218
219
220 int renderTargetWidth = 0;
221 int renderTargetHeight = 0;
222 int windowWidth = 0;
223 int windowHeight = 0;
224
225 glfwGetFramebufferSize(nativeHandle, &renderTargetWidth, &renderTargetHeight);
226 glfwGetWindowSize(nativeHandle, &windowWidth, &windowHeight);
227
228 commandBufferRegistry_->template item<TPlatformCommandBuffer>()
229 ->template add<WindowResizeCommand<THandle>>(
230 cmd.windowHandle,
231 WindowSize(windowWidth, windowHeight),
232 RenderTargetSize(renderTargetWidth, renderTargetHeight));
233
234 return true;
235 }

createWindows()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::createWindows (UpdateContext & updateContext)
inline noexcept

Creates all windows queued during command submission.

Parameters
updateContext

Frame-local update context.

Returns

true if at least one window was created in this flush; otherwise false.

Definition at line 345 of file GLFWPlatformManager.ixx.

345 bool createWindows(UpdateContext& updateContext) noexcept {
346 if (windowCreateCommands_.empty()) {
347 return false;
348 }
349 for (const auto& windowCreateCommand : windowCreateCommands_) {
350 const bool isContextAvailable = createWindow(updateContext, windowCreateCommand);
351 if (!isContextAvailable) {
352 logger_.error("Failed to create window");
353 assert(false && "Failed to create window");
354 }
355 }
356
357 windowCreateCommands_.clear();
358 return true;
359 }

initPlatform()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::initPlatform (UpdateContext & updateContext)
inline noexcept

Initializes GLFW and transitions runtime/session from booting to boot request.

Parameters
updateContext

Frame-local update context.

Definition at line 131 of file GLFWPlatformManager.ixx.

131 bool initPlatform(UpdateContext& updateContext) noexcept {
132
133 if (!shouldInit_ || initialized_) {
134 return false;
135 }
136
137 if (glfwInit() == GLFW_FALSE) {
138 assert(false && "Failed to initialize glfw");
139 }
140
141 renderPlatform_.provideWindowHints();
142
143 assert(updateContext.session().state<EngineState>() == EngineState::Booting &&
144 "Expected EngineState to be Booting during platform initialization");
145
146 initialized_ = updateContext.session().initialize() &&
147 updateContext.runtimeEnvironment().initialize();
148
149 shouldInit_ = false;
150
151 return initialized_;
152 }

installResizeListener()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::installResizeListener (THandle handle)
inline noexcept

Installs GLFW user-pointer data and renderTarget resize callback for a window.

Parameters
handle

Window handle for which the listener is installed.

Definition at line 261 of file GLFWPlatformManager.ixx.

261 void installResizeListener(THandle handle) noexcept {
262
263 auto entity = platformWorld_->findEntity<THandle>(handle);
264
265 if (!entity) {
266 logger_.warn("Entity was not found");
267 return;
268 }
269
270 const auto* glfw = entity->template get<GLFWWindowHandleComponent<THandle>>();
271 if (!glfw) {
272 logger_.error("Entity does not have GLFWWindowHandleComponent");
273 assert(false && "Entity does not have GLFWWindowHandleComponent");
274 return;
275 }
276
277 auto* wuptrComponent = entity->template get<GLFWWindowUserPointerComponent<THandle, TPlatformCommandBuffer>>();
278 if (!wuptrComponent) {
279 logger_.error("Entity does not have GLFWWindowUserPointerComponent");
280 assert(false && "Entity does not have GLFWWindowUserPointerComponent");
281 return;
282 }
283 auto* wuptr = &wuptrComponent->userPointer;
284
285 glfwSetWindowUserPointer(glfw->handle, static_cast<void*>(wuptr));
286
287 glfwSetFramebufferSizeCallback(
288 glfw->handle,
289 [] (GLFWwindow* nativeHandle, const int width, const int height) {
290 const auto* ptr = static_cast<GLFWWindowUserPointer<THandle, TPlatformCommandBuffer>*>(glfwGetWindowUserPointer(nativeHandle));
291
292 if (ptr && ptr->platformCommandBuffer) {
293
294 int windowWidth = 0;
295 int windowHeight = 0;
296
297 glfwGetWindowSize(nativeHandle, &windowWidth, &windowHeight);
298 ptr->platformCommandBuffer->template add<WindowResizeCommand<THandle>>(
299 ptr->windowHandle,
300 WindowSize(windowWidth, windowHeight),
301 RenderTargetSize(width, height)
302 );
303 }
304 });
305 }

pollEvents()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::pollEvents (UpdateContext & updateContext)
inline noexcept

Polls GLFW events if requested by a poll-events command.

Parameters
updateContext

Frame-local update context.

Definition at line 422 of file GLFWPlatformManager.ixx.

422 void pollEvents(UpdateContext& updateContext) noexcept {
423 if (!pollEvents_) {
424 return;
425 }
426
427 glfwPollEvents();
428 pollEvents_ = false;
429 }

removeCurrentContext()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::removeCurrentContext (UpdateContext & updateContext)
inline

Removes CurrentContextComponent from all windows currently marked as active context.

Parameters
updateContext

Frame-local update context.

Definition at line 242 of file GLFWPlatformManager.ixx.

242 void removeCurrentContext(UpdateContext& updateContext) {
243 // remove any currentcontext component
244 currentContexts_.clear();
245 for (auto [window, cc]: updateContext.template view<THandle, CurrentContextComponent<THandle>>()) {
246 currentContexts_.push_back(window.handle());
247 }
248 for (auto& handle : currentContexts_) {
249 auto go = updateContext.find<THandle> (handle);
250 if (go) {
251 go->template remove<CurrentContextComponent<THandle>>();
252 }
253 }
254 }

resizeWindows()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::resizeWindows (UpdateContext & updateContext)
inline noexcept

Applies queued resize commands to window components.

Applies queued resize commands to window components. This will also affect the underlying renderTargets, for as long as the specific windows are bound to a renderTarget.

Parameters
updateContext

Frame-local update context.

Definition at line 370 of file GLFWPlatformManager.ixx.

370 void resizeWindows(UpdateContext& updateContext) noexcept {
371
372 if (pendingResizeCommands_.empty()) {
373 return;
374 }
375
376 for (const auto& [windowHandle, windowSize, renderTargetSize]: pendingResizeCommands_) {
377
378 if (!windowHandle.isValid()) {
379 continue;
380 }
381
382 if (auto entity = updateContext.find(windowHandle)) {
383
384 if (auto* wsc = entity->template get<Size2DComponent<THandle>>()) {
385 wsc->setValue(windowSize);
386 }
387 if (auto* fbc = entity->template get<RenderTargetBindingComponent<THandle>>()) {
388 auto renderTargetHandle = fbc->targetHandle();
389 auto renderTarget = updateContext.find<RenderTargetHandle>(renderTargetHandle);
390 auto fsc = renderTarget->template get<Size2DComponent<RenderTargetHandle>>();
391
392 logger_.info("Setting renderTarget size to {0},{1}", renderTargetSize[0], renderTargetSize[1]);
393 fsc->setValue(renderTargetSize);
394 }
395 }
396
397 }
398
399 pendingResizeCommands_.clear();
400 }

shutdown()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::shutdown (UpdateContext & updateContext)
inline noexcept

Terminates GLFW and queues a shutdown state transition request.

Parameters
updateContext

Frame-local update context.

Definition at line 469 of file GLFWPlatformManager.ixx.

469 void shutdown(UpdateContext& updateContext) noexcept {
470
471 glfwTerminate();
472
473 commandBufferRegistry_->template item<TStateCommandBuffer>()->template add<StateCommand<EngineState>>(
474 StateTransitionRequest<EngineState>(
475 updateContext.session().state<EngineState>(),
476 EngineStateTransitionId::ShutdownRequest
477 )
478 );
479
480
481 }

swapBuffer()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::swapBuffer (UpdateContext & updateContext, const SwapBuffersCommand< THandle > & cmd)
inline noexcept

Executes a single swap-buffers command.

Parameters
updateContext

Frame-local update context.

cmd

Swap-buffers command.

Definition at line 314 of file GLFWPlatformManager.ixx.

314 void swapBuffer(UpdateContext& updateContext, const SwapBuffersCommand<THandle>& cmd) noexcept {
315
316 const auto entity = updateContext.find(cmd.windowHandle);
317
318 if (!entity) {
319 logger_.warn("Entity was not found");
320 return;
321 }
322
323 const auto* glfw = entity->template get<GLFWWindowHandleComponent<THandle>>();
324
325 if (!glfw) {
326 logger_.error("Entity does not have GLFWWindowHandleComponent");
327 assert(false && "Entity does not have GLFWWindowHandleComponent");
328 return;
329 }
330
331 assert((updateContext.session().state<EngineState>() != EngineState::Booting) &&
332 "GLFWSwapBuffersSystem should not be running during boot");
333 assert(glfw->handle && "GLFWWindowComponent has no native handle");
334 glfwSwapBuffers(glfw->handle);
335 }

swapBuffers()

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
void helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::swapBuffers (UpdateContext & updateContext)
inline noexcept

Processes all queued swap-buffers commands.

Parameters
updateContext

Frame-local update context.

Definition at line 407 of file GLFWPlatformManager.ixx.

407 void swapBuffers(UpdateContext& updateContext) noexcept {
408 if (pendingBufferSwaps_.empty()) {
409 return;
410 }
411 for (const auto& swapBufferCommand : pendingBufferSwaps_) {
412 swapBuffer(updateContext, swapBufferCommand);
413 }
414 pendingBufferSwaps_.clear();
415 }

Private Member Attributes

commandBufferRegistry_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
CommandBufferRegistry* helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::commandBufferRegistry_ = nullptr

Definition at line 483 of file GLFWPlatformManager.ixx.

483 CommandBufferRegistry* commandBufferRegistry_ = nullptr;

currentContexts_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
std::vector<THandle> helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::currentContexts_

Definition at line 109 of file GLFWPlatformManager.ixx.

109 std::vector<THandle> currentContexts_;

initialized_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::initialized_ = false

Definition at line 117 of file GLFWPlatformManager.ixx.

117 bool initialized_ = false;

pendingBufferSwaps_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
std::vector<SwapBuffersCommand<THandle> > helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::pendingBufferSwaps_

Definition at line 105 of file GLFWPlatformManager.ixx.

105 std::vector<SwapBuffersCommand<THandle>> pendingBufferSwaps_;

pendingCloseCommands_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
std::vector<WindowCloseCommand<THandle> > helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::pendingCloseCommands_

Definition at line 107 of file GLFWPlatformManager.ixx.

107 std::vector<WindowCloseCommand<THandle>> pendingCloseCommands_;

pendingResizeCommands_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
std::vector<WindowResizeCommand<THandle> > helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::pendingResizeCommands_

Definition at line 101 of file GLFWPlatformManager.ixx.

101 std::vector<WindowResizeCommand<THandle>> pendingResizeCommands_;

platformWorld_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
PlatformWorld* helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::platformWorld_

Definition at line 124 of file GLFWPlatformManager.ixx.

124 PlatformWorld* platformWorld_;

pollEvents_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::pollEvents_ = false

Definition at line 115 of file GLFWPlatformManager.ixx.

115 bool pollEvents_ = false;

renderPlatform_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
TRenderPlatform& helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::renderPlatform_

Definition at line 119 of file GLFWPlatformManager.ixx.

119 TRenderPlatform& renderPlatform_;

shouldInit_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::shouldInit_ = false

Definition at line 111 of file GLFWPlatformManager.ixx.

111 bool shouldInit_ = false;

shouldShutdown_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
bool helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::shouldShutdown_ = false

Definition at line 113 of file GLFWPlatformManager.ixx.

113 bool shouldShutdown_ = false;

windowCreateCommands_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
std::vector<WindowCreateCommand<THandle> > helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::windowCreateCommands_

Definition at line 103 of file GLFWPlatformManager.ixx.

103 std::vector<WindowCreateCommand<THandle>> windowCreateCommands_;

Private Static Attributes

logger_

template <typename TRenderPlatform, typename THandle, typename TStateCommandBuffer = NullCommandBuffer, typename TPlatformCommandBuffer = NullCommandBuffer>
const helios::engine::util::log::Logger& helios::glfw::GLFWPlatformManager< TRenderPlatform, THandle, TStateCommandBuffer, TPlatformCommandBuffer >::logger_
static
Initialiser
= helios::engine::util::log::LogManager::loggerForScope( HELIOS_LOG_SCOPE)

Definition at line 121 of file GLFWPlatformManager.ixx.

121 inline static const helios::engine::util::log::Logger& logger_ = helios::engine::util::log::LogManager::loggerForScope(

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.