Repository navigation
render: make factory's shared rendering context current when the last render context is destroyed - #199
Merged
Conversation
… render context is destroyed
This was referenced Nov 26, 2026
Merged
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #199 +/- ##
==========================================
+ Coverage 28.53% 28.55% +0.01%
==========================================
Files 239 239
Lines 8943 8945 +2
Branches 2785 2785
==========================================
+ Hits 2552 2554 +2
Misses 6057 6057
Partials 334 334 ☔ View full report in Codecov by Harness. |
igagis
reviewed
Nov 26, 2026
igagis
reviewed
Nov 26, 2026
igagis
previously approved these changes
Nov 26, 2026
…t(native_window&)
igagis
previously approved these changes
Nov 26, 2026
igagis
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the last
ruis::render::contextis destroyed, no rendering context remains current on the thread. On Windows (WGL), any subsequent GL call then fails withGL_INVALID_OPERATION— including the destruction of the shared render objects (shaders, buffers, ...) owned by theruis::render::factory, which happens right after the contexts are destroyed on application shutdown.Add a protected virtual
ruis::render::factory::bind()(empty by default, for renderers without a notion of a current context, e.g. Vulkan) and call it from~context()when no render contexts are left, so that the factory's shared rendering context is made current before the shared render objects are destroyed. GL-based renderer factories overridebind()to make their shared (headless) GL context current (companion PRs: cppfw/ruis-render-opengl and cppfw/ruis-render-opengles).native_window::bind_rendering_context()is made public so the factories can call it directly; this removes the need for thefriend class ruis::render::factoryrelation and the former protectedfactory::bind(native_window&)helper.