cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.31k stars 939 forks source link

Make Ref arguments `const` for ScopedVao and ScopedGlslProg #2237

Closed totalgee closed 2 years ago

totalgee commented 3 years ago

Minor change, just to be consistent with other scoped Ref types, and allowing const draw() methods to use these scoped objects.

totalgee commented 3 years ago

Bump...? 😉

richardeakin commented 3 years ago

I believe there was a specific reason for this though I can't remember exactly what that was. Something @andrewfb found as an optimization when there were many many ScopedVaos and ScopedGlslProgs (I think it was related to the Earth sample).

totalgee commented 3 years ago

Actually, these changes shouldn't affect anything to do with whether the Scoped object (GlslProg or Vao) has const or non-const access, because this is just the shared_ptr (the "Ref") we're talking about. I see that some of the Scoped helpers take a const pointer (GlslProg) vs a non-const (Vao), but this won't be affected by this PR. (also, ScopedGlslProg actually takes a shared_ptr to a const GlslProg). Anyhow, it's not super important and I do get what you're saying @richardeakin , but the truth is that making the shared_ptr argument itself const reference or not should make no difference, since the constructor then takes a pointer to the pointed-to object using get(). Do you want to integrate this, or should I retract it?