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
6
#include "
../core/EstellaContext.hpp
"
7
#include "
EngineContext.hpp
"
// unset-fallback default context (see activeCtx)
8
9
namespace
esengine
{
10
16
inline
EstellaContext
*
g_activeContext
=
nullptr
;
17
#ifdef ES_RENDER_THREADS
18
inline
thread_local
EstellaContext
* renderOwnerContext =
nullptr
;
19
#endif
20
37
inline
EstellaContext
&
activeCtx
() {
38
#ifdef ES_RENDER_THREADS
39
if
(renderOwnerContext)
return
*renderOwnerContext;
40
#endif
41
return
g_activeContext
? *
g_activeContext
:
EngineContext::instance
().
context
();
42
}
43
44
inline
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
EngineContext.hpp
EstellaContext.hpp
Instance-based engine context for estella renderer.
esengine::EngineContext::context
EstellaContext & context()
Definition
EngineContext.hpp:25
esengine::EngineContext::instance
static EngineContext & instance()
Definition
EngineContext.cpp:8
esengine::EstellaContext
Definition
EstellaContext.hpp:24
esengine::EstellaContext::renderThread
RenderThread & renderThread()
Definition
EstellaContext.hpp:63
esengine::RenderThread::invoke
decltype(auto) invoke(F &&fn)
Definition
RenderThread.hpp:89
esengine
Definition
EasingFunctions.hpp:10
esengine::startRenderThread
bool startRenderThread(EstellaContext &context, const char *canvas=nullptr)
Definition
ActiveContext.hpp:44
esengine::activeCtx
EstellaContext & activeCtx()
The engine context every binding routes through — single source of truth.
Definition
ActiveContext.hpp:37
esengine::g_activeContext
EstellaContext * g_activeContext
The explicitly-installed active engine context (or null if none).
Definition
ActiveContext.hpp:16
src
esengine
bindings
ActiveContext.hpp
Generated by
1.15.0