New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow re-creation of the shared context as a core context #1443
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the provide program and the patch indeed fixes it. I haven't tested more complex programs though.
src/SFML/Window/GlContext.cpp
Outdated
{ | ||
const char* extension = extensionString; | ||
|
||
while(*extensionString && (*extensionString != ' ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space: while_(
@@ -446,6 +471,25 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width | |||
|
|||
Lock lock(mutex); | |||
|
|||
// If resourceCount is 1 we know that we are inside sf::Context or sf::Window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRY code: re-factor this code and the identical one from above into a function. Maybe a template function to accommodate for the width/height vs owner/bpp difference? If the logic is the same (except how context
is constructed), I think it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially tried to do this, but GlContext::initialize()
is private.
src/SFML/Window/Win32/WglContext.cpp
Outdated
// The shared context is the context used to initialize the extensions | ||
if (shared && shared->m_deviceContext) | ||
ensureExtensionsInit(shared->m_deviceContext); | ||
|
||
// Create the rendering surface (window or pbuffer if supported) | ||
createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel); | ||
|
||
// Create the context | ||
if (m_deviceContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, I would also DRY the ctors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delegating constructors are coming in C++11. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! Maybe add a \todo
so we actually clean up the code at some point?
48b1eef
to
eb2316d
Compare
There... should be a bit better now. The amount of code duplication can probably be significantly reduced in C++11. I wouldn't invest too much time in trying to minimize the lines of code right now. |
eb2316d
to
769d58e
Compare
… indicates they want a core profile context. Sharing of compatibility and core profile contexts is not possible on macOS which is why we need to have a way to re-create the shared context as a core context if required in this case.
769d58e
to
ac98be7
Compare
Allow re-creation of the shared context as a core context if the user indicates they want a core profile context. Sharing of compatibility and core profile contexts is not possible on macOS which is why we need to have a way to re-create the shared context as a core context if required in this case.
The following code breaks on macOS without this change: