A Few Hints and Tips
This is going to be a big old read. Because there's a lot of optimising that can be done with the book code.
Its easy to think that because code runs, its running well, but in actual fact, our basic book code, pretty much from day 1 has been running very poorly.
Why you may ask? And rightly so. Did I not know it was running poorly? Well yes, but I left it like that because optimising code, is the single best way to make code unreadable.
All through the development of my book and lessons, I strive to make things readable. But if you've got to the stage when everything works and you feel comfortable about that, its time to start thinking about how to make it faster
We're not going to do too much here with making the main code faster, becuase thats going to very much depend on your project specifics and also what cpu you are running on, how you use the memory are you using cores etc. We're instead going to focus on the main bottlnecks that slow down our GPU.
And that generally boils down to these things:
"Draw calls"; also more generally glXXXX calls of any kind. Which can make the difference between your game comfortably running at 60fps in 1080p or have it crawling at 12fps.
They are needed of course, we can't draw without making a draw call, and we have to set things up, but when, and how often are important questions to ask ourself.
A few simple changes to code can make massive improvements, but it can also be hard to see where those changes can be applied and what they actually do. Lets go through it.