A very nice person, by the name of Allen B. Downey, has written several textbooks. All of which are available under free licences. So you can have the source and tinker with them.
A few years ago, I adopted his free-content C++ book as my standard course text. Since then, I’ve made a few updates every year. The latest version is downloadable from Google Docs.
I have an update to “my” OpenGL book in the pipeline too.