/* Add Tip CTA */ .add-tip { padding: 40px 0; text-align: center; background-color: #f0f5fb; }
Make your games run faster and more efficiently
This is going to be a big old read. Because there's a lot of optimising that can be done with the book code.
It's easy to think that because code runs, it's 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, it's 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, because that's 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 bottlenecks that slow down our GPU.
glDrawArrays(GL_TRIANGLES, 0, numberTri);
"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.
TBC.
vec4 position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0);
This is a placeholder for a future tip about optimizing shader code.
You would explain shader optimization techniques here, with code examples and specific recommendations.
This format can be used for each new optimization tip you add to the page.
// Batch processing example code
This is a placeholder for a future tip about batch processing for optimized rendering.
You would explain batch processing techniques here, with code examples and specific recommendations.
The alternating layout ensures visual variety as users scroll through the tips.
Explore detailed techniques for reducing draw calls and optimizing render pipelines.
Read TutorialLearn how to efficiently manage GPU memory and reduce memory-related bottlenecks.
Read TutorialAdvanced techniques for writing efficient shader code and avoiding common pitfalls.
Read TutorialCheck back regularly for new optimization techniques and tips
Discuss in Forums