
Learn to build a 2D rendering library in C++ and OpenGL, featuring a 2D batch renderer, shapes, textures, camera, texture atlas, and text rendering, with practical CMake setup.
Choose cmake as the build system for this project, while the library remains two files you can add to any OpenGL setup; optional cmake tutorials accompany the course.
Learn to set up and open a CMake project, compare generic and IDE-integrated workflows, manage build folders, and configure production versus development builds with the resources path macro.
Learn the essentials of CMake by building a simple CMake project from scratch, creating CMakeList.txt, declaring projects, executables, and libraries, and linking dependencies with include directories and third-party libraries.
Discover the five pillars of good library design—easy linking, easy to use, hard to use wrong, versatile APIs, and non-enforcing patterns, illustrated with real-world C++ and OpenGL examples.
Adopt a minimalist, iterative mindset when building a 2D library in C++ and OpenGL: start simple, test with real use, and add abstractions only when needed.
Learn how to structure a lightweight 2D rendering library named Pixie for OpenGL, designed as header and source only with GLM, a simple demo, and a minimal CMake setup.
Design the shader struct to load OpenGL shaders with a simple, user-friendly interface. Implement manual memory management, provide default and customizable shaders, and offer non-intrusive loading helpers.
Learn to implement error reporting by allowing a custom error function and user data, with a default console reporter and a reportError function used for shader loading.
Implement the textures track to load and draw textures from file or memory, with mipmaps and filters. Provide helpers like getSize, readTextureData, and bind for flexible texture management.
Implement init and cleanup for the 2d rendering library in c++ and OpenGL, using a default global shader and texture, guarded by a hasInitialized flag and OpenGL-load checks.
Starting the basic renderer, this lecture shows a single function to render textured triangles, introduces batch rendering with flush, and explains portability across OpenGL and other backends.
Render triangles with multiple textures by using a per-triangle texture list and a default white texture. Remember to measure first and optimize only if needed, keeping code simple and robust.
Implement the drawRectangle function using pixel coordinates with an orthographic projection, rotate about a pivot, compute corners and UVs, set colors, and render two triangles.
Implement a camera that lets users move, zoom, and rotate, affecting the renderRect via a view matrix that applies camera movement and zoom relative to the center.
Implement a follow camera with smooth movement, min and max distance thresholds, and accurate screen-to-world coordinate conversion via inverse camera matrix, tested with a Terraria-like world.
Implement a texture atlas helper to compute UVs for atlas cells with normalized coordinates and a Vect4, including an optional horizontal flip.
Fix texture atlas sampling bugs from floating point imprecision by enlarging the atlas with 1-pixel padding and filling gaps with neighbor pixels, a structured art debugging approach.
Implement font rendering by rasterizing TrueType fonts into an RGBA texture atlas using stb_truetype, while tracking line height, letter metrics, and space width for efficient 2D text.
Learn to render text in a custom 2D rendering library with C++ and OpenGL by computing text layout, handling spacing, and drawing characters from a font texture atlas.
Learn how to provide a default font in a C++ and OpenGL based 2D rendering library by embedding a font as a byte array and loading it automatically.
Learn to use and manage framebuffers in OpenGL, including creating a framebuffer, texture, and optional depth buffer, binding and resizing safely, and rendering framebuffer content to the main window.
Complete your 2D rendering library, showcase it on GitHub, and plan next steps by tackling harder challenges, starting a project, and building Terraria-like games with UI and shaders.
Low-level game developers: do you want to make your own 2D game/game engine from scratch?
The best place to start is making a 2D library in OpenGL! This library will allow you to make your own 2D games from scratch, and it can also be the starting point for your own game engine! And I will guide you step by step. You also get 20+ guided challenges to do on your own! I will show you how to implement all the things that you need in a 2D library, like text rendering, texture rendering, a proper texture atlas, and a batch renderer.
You just need basic OpenGL experience! (I don't recap basic OpenGL things)
This is also where I started. After making my own 2D library in OpenGL, I unlocked so many cool projects. If you check my YouTube channel (Low Level Game Dev), all 2D games and projects you see there are made using my 2D library! I even made a game engine and published a Steam game, all starting from this one 2D library that we are going to make together now!
Everyone can make a 2D game using a library like Raylib or SFML, but trust me, it feels totally different to make a game using your own 2D library! It's much cooler, and you can design the library to your exact liking!
Have you ever gotten stuck while making a bigger project? I have seen so many students start over projects from scratch because their code becomes unmaintainable. Or maybe you just had too many bugs in your code. And the bigger the project is, the harder it gets to maintain it. But there is a way to not have that problem again. You just have to approach your coding a little differently. It is something called approach-based design, and it's not hard, but you just need someone to constantly remind you about it so you form the habit.
So, besides the 2D library that we will make together, I will constantly point out how I made certain decisions and how I organized my code. In this way, you will unlearn the common programming mistakes and learn some actual good programming practices for the rest of your life.
I will also teach you the 5 pillars of a good library design. And you won't just get some boring theory; we will use these principles for the entire library so that by the end of the course, you will know how to design a good C++ library and also robust code in general. This skill will apply to your next projects, like making a big game or a game engine! I also bring some cool examples from other good C++ libraries.
Good code comes from some simple good habits, like learning to check for failure points. People usually teach design patterns and algorithms instead of focusing on these details, and that's why once you make a big project, you start having problems. So in this course, I highlight all of these little things so you learn to recognize them and apply them in your own projects!
Things Included:
How to make a 2D library in OpenGL - The perfect start for your low-level game dev journey!
How to implement a 2D batch renderer - This is basically how a 2D rendering library should be implemented.
Proper texture atlas implementation. - Texture atlases have an annoying bug that I show how to properly fix!
Text rendering - This is the hardest topic, but I will help you get through it and have a proper implementation!
How to organize a C/C++ library - I have seen so many beginners organize libraries in weird ways, that's ok, it also took me many years, but with this course, I will help you skip that process!
The 5 pillars of good library design - I will teach you practices that actually make your library easy to use and easy to debug.
How to use CMake - I have a full CMake tutorial included, and I also show how I configure CMake for a library.
Guided challenges to do on your own - you don't learn unless you practice, so I have 20+ guided challenges for you!
Directions to continue adding UI rendering to this library - I will give you some tips about what to do after finishing the library!
Throughout my YouTube career, I have seen so many people make the exact same mistakes, so I can confidently say that this course will place you on the right track to making your own games or game engine from scratch in C++. All starting from this 2D rendering library. And yes, you can also make this on your own, but after making so many games, I know all the pitfalls there are in making such a project, like texture atlas problems or font rendering problems. I will point them out for you, so you can focus on writing code instead of searching the sollution for a bug that you don't even understand (I was in that situation).
So you get a 2D library course in OpenGL + how to properly design C++ libraries + good coding practices + many other small details +
Some cool extras!
A cheat sheet for the 5 pillars of good library design
Extra: A quiz for the 5 pillars of good library design
More Extra: Cool debugging tips.
Even More: Cool project ideas you can implement with the library after you finish
And finally, you can share your result pictures with other students!
I put a lot of work into planning, scripting, and editing this course to make it clear and easy to follow, so it will work for you! If you're still not sure, you can look at the first lessons for free!
So join my course now to take your first step on your C++ gamedev journey and make your own 2D library!
P.S. - Yes, you can learn all these things online for free. That's how I learned, too, in my 10 years of coding. But this course is a shortcut that helps you skip common mistakes. If you want to do projects like the ones I show on my YouTube channel, this course is made to help you get there faster than the 10 years I had to spend!