cginternals / globjects

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

Outdated documentation concerning memory model #365

Open X-Ryl669 opened 6 years ago

X-Ryl669 commented 6 years ago

On the main page, the documentation talk about using ref_ptr for memory management, but none of the code does that. It's not clear what is the current memory model expectation from globjects now it's using unique_ptr, so I guess a update of the documentation is required.

It should answer these questions:

  1. When the globject interface use a plain pointer, who is managing the pointer lifetime (is it owned by globjects or should we keep track of them ourselves) ?
  2. unique_ptr usually means that we (users) need to deal with the pointer's life (and unique_ptr is doing exactly this for us), yet some of the globjects API is using plain pointers. Do we need to reassign the pointer if we update the owned object ? For example, in Program::attach(Shader * shader), do we need to detach and attach a new Shader if it's destructed / re-allocated on our side? Or is it magically done through the listener interface?
  3. Entanglement is not clear. Program have a pointer on the Shader, but Shader also take a pointer on the Program in the attach method. Who should delete the other ?
  4. Exception safety... that's a huge question by itself
  5. Dependence on the GL context ? Is a globject::XXX instance working correctly if used in a static singleton (thus destructed after main() is done and the GL context has vanished ?