cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
539 stars 59 forks source link

Example from the documentation on context initialization causes stack overflow #406

Open andesyv opened 2 years ago

andesyv commented 2 years ago

In the Initialize Contexts section of the documentation it states you can sync OpenGL contexts using glbinding by doing:

glbinding::Binding::addContextSwitchCallback([](glbinding::ContextHandle handle) {
    setContext(handle);
});

And then do

glbinding::Binding::useContext(handle);

to notify globjects and glbinding of the switch. But in source/globjects/source/globjects.cpp#L177 it looks like globjects::setContext(glbinding::ContextHandle handle) calls glbinding::Binding::useContext(glbinding::ContextHandle handle) internally, causing an infinite call chain and a stack overflow.

Just removing the section is probably enough to fix this, but it would be nice if it also explicitly states that the init, setContext and setCurrentContext globject functions also internally calls the glbinding equivalents.