Skip to content

Conversation

Megamouse
Copy link
Contributor

This code causes exceptions in debug builds if not called from the main thread.

{
const auto context = static_cast<GLContext*>(ctx);

if (context->handle->makeCurrent(context->surface))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This is wrong.
GLRC makeCurrent means "make this context the current one on this thread".
We don't want it attached to main thread, we want it attached to the caller. It's how you do multithreading in OGL.

const auto gl_ctx = static_cast<GLContext*>(ctx);

gl_ctx->handle->doneCurrent();
// Calling this on the main thread is necessery in debug builds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, cannot be done from main thread. Anything with "current" is thread-local

@Megamouse Megamouse marked this pull request as draft March 11, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants