Sprite Batching In OpenGL (Uniform Buffer Objects) // OpenGL Tutorial #33

Опубликовано: 09 Февраль 2025
на канале: OGLDEV
10,637
247

In this video we take a break from 3D and explore 2D rendering using a sprite batching technique in OpenGL. This is also a great opportunity to get introduced to Uniform Buffer Objects which is a more efficient way of loading uniforms than the method that we've been using so far, especially when you have many of them. UBOs can be used for 3D as well so even if you don't plan on doing 2D rendering you should definitely learn about them.

🔥 See the list of the books that I'm using as background information for my tutorials: https://ogldev.org/books.html. I highly recommend them for learning more about OpenGL and Vulkan. These are affiliate links so if you use them to buy any of the books the price is the same for you and I will get a small commission (thank-you!).

The sprites that I used are from https://www.gameart2d.com
Free texture packing tool: https://www.codeandweb.com/tp-online

Timecodes
0:00 Intro
0:26 Sprite Batching
1:54 Calculating sprite size in texture space
2:34 Screen space to NDC
2:47 Sprite batching solution
4:09 The vertex shader
4:54 The fragment shader
5:52 Supporting multiple sprite sheets
6:03 The QuadArray class
6:37 The SpriteBatch class
8:22 Simple animation example
8:35 Efficiency of uniform variables
9:08 Uniform Buffer Objects
13:40 Conclusion

Make sure to watch all the previous tutorials in the "OpenGL For Beginners" playlist at    • OpenGL for Beginners  

Please visit https://ogldev.org to see more of my tutorials on modern OpenGL.

Link to source: https://github.com/emeiri/ogldev/blob...
OpenGL 4.6 specification: https://www.khronos.org/registry/Open...

Feel free to comment below.

Email: [email protected]
Github: https://github.com/emeiri/ogldev.git
Twitter: @ogldev
One time donations (Paypal): https://ogldev.org/donate.html
Patreon:   / ogldev  

Enjoy,

Etay Meiri

#opengl #ogldev #opengtutorials