openframeworks / openframeworks/openFrameworks
[Desktop / GLFW] Features proposal : untethered context creation and OpenGL Compatibility Profile.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Hello everyone,
For a project I needed to access the last features of libVLC 4.0 that runs its instance on a separated thread with a shared OpenGL context.
Two issues arised :
- libVLC requiered an OpenGL
Compatibility Profilewhere OpenFrameworks is bound toCore Profile¹. - Window creation links² the window to the windowApp map and make its context current on the main thread every frame³, breaking the context when used simultaneously in another thread.
References :
- 1 : Forced Core Profile on OpenGL 3.2+.
https://github.com/openframeworks/openFrameworks/blob/ce1bbc751595881398934e82029d74fe099899c5/libs/openFrameworks/app/ofAppGLFWWindow.cpp#L200 - 2 : Tethered GLFW window / context creation.
https://github.com/openframeworks/openFrameworks/blob/ce1bbc751595881398934e82029d74fe099899c5/libs/openFrameworks/app/ofMainLoop.cpp#L68 - 3 : Main thread preempting the window context every loop.
https://github.com/openframeworks/openFrameworks/blob/ce1bbc751595881398934e82029d74fe099899c5/libs/openFrameworks/app/ofMainLoop.cpp#L147
Proposed implementations :
The workarounds are simple and supposedly break-free.
For the first case, we can add a boolean flag in ofGLFWWindowSettings to use GLFW_OPENGL_COMPAT_PROFILE
instead of GLFW_OPENGL_CORE_PROFILE.
For the second case, we can either create an ofCreateContext function or add a boolean in settings (eg. useCustomThread) that pass ofMainloop.cpp#L68.
Here is an example that set off every graphics presenting capabilities, unasked for in a windowless context :
shared_ptr<ofAppBaseWindow> ofCreateContext(const ofWindowSettings & _settings) {
ofGLFWWindowSettings settings(_settings);
settings.doubleBuffering = false;
settings.visible = false;
settings.setSize(1, 1);
shared_ptr<ofAppGLFWWindow> context = std::make_shared<ofAppGLFWWindow>();
context->setup(settings);
context->setVerticalSync(false);
return context;
}
Any thoughts on this ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with libs/openFrameworks/app/ofAppGLFWWindow.cpp for the referenced OpenGL profile setup and libs/openFrameworks/app/ofMainLoop.cpp for window registration and context-current behavior. Compare the proposed settings flag and context-creation alternatives; done means compatibility-profile selection and an untethered, windowless shared context are supported without the main loop reclaiming the context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100