Conversation
The bind()/unbind() and its attached thread concept is not suitable with the context management of GLFW. Binding was meant to be equivalent with making context current with glfwMakeContextCurrent() but with an addition of tracking the calling thread inside Window. This however won't work correctly since when changing current context the previous window should unbind() itself before the new one bind() itself. In the case unbind() not called for previous window, both will have the same attached thread which should not happen! In GLFW there is no such thing anyway so removing these interfaces is best.
In the meantime I also removed task queue.
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.
This PR fixes #8
There are many changes introduced in this PR:
Rework the logic for library initialization and add initialization hints.
I changed the signature for
glfw_cpp::inittowhere
glfw_cpp::InitHintis initialization hints as described in the docs.This change in turn removes the need to initialize which client API to use for subsequent
Windowcreated by GLFW.The struct is an aggregate of all the hints available as its field, making setting them easier at initialization:
Make the window creation hints setting in-line with GLFW and aggregate all the hints into one type.
Initialization hints now can be set independent of
Windowcreation. The hints also "sticks" globally just like what GLFW does. The interface for this isglfw_cpp::Instance::apply_hint*.The change removes the previous limitation of only one client API for all windows. Now with this you can mix the API.
Add missing hints, add several new type representing the hints, and replace current
Hintstruct with a new one that aggregates all the hints into one struct with (may be fields).All the hints including platform specific ones are now included in the library. The
glfw_cpp::Apistruct and its corresponding types insideglfw_cpp::apinamespace are largely the same. The hints can be set using previous function:Remove the conception of
bind()/unbind()or make the context management match underlying GLFW.Since the abstraction provided by both functions are faulty, I decided to remove both functions and revert to how the underlying library does the context management. Two functions are introduced as wrapper:
glfw_cpp::make_currentwhich wrapsglfwMakeContextCurrent, andglfw_cpp::get_currentwhich wrapsglfwGetCurrentContext.Rename
glfw_cpp::Window::pollandglfw_cpp::Window::displaytoglfw_cpp::Window::swap_eventsandglfw_cpp::Window::swap_buffers.glfw_cpp::Window::polldoesn't do any polling, it just swaps the window event queue. The polling is done byglfw_cpp::Instance::poll_eventswhich makes the function name misleading. Furthermore they have too similar of function name so it might introduce confusion.glfw_cpp::Window::displayalso just swaps buffers. The new name also more in-line withglfwSwapBufferwhich is what it calls under.