Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ActiveContext.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
3#pragma once
4
5
7#include "EngineContext.hpp" // unset-fallback default context (see activeCtx)
8
9namespace esengine {
10
17#ifdef ES_RENDER_THREADS
18inline thread_local EstellaContext* renderOwnerContext = nullptr;
19#endif
20
38#ifdef ES_RENDER_THREADS
39 if (renderOwnerContext) return *renderOwnerContext;
40#endif
42}
43
44inline bool startRenderThread(EstellaContext& context, const char* canvas = nullptr) {
45#ifdef ES_RENDER_THREADS
46 auto& queue = context.renderThread();
47 if (!queue.start(canvas)) return false;
48 queue.invoke([&] { renderOwnerContext = &context; });
49 return true;
50#else
51 (void)context;
52 (void)canvas;
53 return false;
54#endif
55}
56
57} // namespace esengine
58
Instance-based engine context for estella renderer.
EstellaContext & context()
static EngineContext & instance()
RenderThread & renderThread()
decltype(auto) invoke(F &&fn)
bool startRenderThread(EstellaContext &context, const char *canvas=nullptr)
EstellaContext & activeCtx()
The engine context every binding routes through — single source of truth.
EstellaContext * g_activeContext
The explicitly-installed active engine context (or null if none).