diff --git a/src/ruis/render/context.cpp b/src/ruis/render/context.cpp index 77a1857ac..d6c926ac5 100644 --- a/src/ruis/render/context.cpp +++ b/src/ruis/render/context.cpp @@ -23,7 +23,7 @@ along with this program. If not, see . using namespace ruis::render; -std::vector ruis::render::context::cur_context_stack; +std::vector ruis::render::context::cur_context_stack; context::context( utki::shared_ref native_window, // diff --git a/src/ruis/render/context.hpp b/src/ruis/render/context.hpp index 1e686156f..83a11936d 100644 --- a/src/ruis/render/context.hpp +++ b/src/ruis/render/context.hpp @@ -36,7 +36,7 @@ class context : public std::enable_shared_from_this friend class frame_buffer; // Context destruction is rare, so removing from the middle of stack is rare, ok to use std::vector. - static std::vector cur_context_stack; + static std::vector cur_context_stack; protected: utki::shared_ref get_shared_ref() @@ -57,8 +57,10 @@ class context : public std::enable_shared_from_this * @brief Get the currently active rendering context. * * The context stack is maintained by apply(). This returns the top of the stack. + * A non-const reference is returned because rendering mutates the active context + * (frame state, draw commands); the context is owned by the code that created it. */ - static const context& current() noexcept + static context& current() noexcept { utki::assert(!cur_context_stack.empty(), SL); return *cur_context_stack.back();