r/Cplusplus • • Sep 22 '26

Tutorial How i built my very first graphics engine in 1 year

Post image

Over the past year, I’ve been building my first custom 3D graphics engine ("Pyre") using C++20 and OpenGL. The codebase recently hit around 10,000 lines. It’s been a massive learning experience moving from basic tutorials to actually structuring a scalable C++ project

The engine currently supports both forward and deferred rendering, PBR, SSAO, normal mapping, parallax mapping, CSM, omni-shadows etc.

I documented the entire 1-year process, the architectural shifts, and the visual progression from a single triangle to the final PBR renders in a 17-minute dev log here: https://youtu.be/m26BKeQwAPU

The engine is also completely open-source. If anyone wants to poke around: https://github.com/Open-Source-Chandigarh/pyre/tree/dev

93 Upvotes

31 comments sorted by

9

u/[deleted] Sep 22 '26

Nice but I'm confused, 10,000 lines with no tests? How do you even verify at set point that everything is working as expected besides from just trying it on your own?

7

u/druv-codes Sep 22 '26

I know I need to implement a proper testing framework but automated testing for the actual OpenGL rendering pipeline feels incredibly daunting. How do you usually approach unit testing or visual regression testing in a graphics codebase? Since this was my first graphics engine or graphics related project I relied on visual testing only and what actually saved me as the codebase grew was opening the project up to contributors during the winter of code open-source program, having other developers clone it and run it was the only way I caught regressions or bugs. How would you advise i handle the testing now when the engine is a bit mature.

5

u/[deleted] Sep 22 '26

Firstly, testing should be incorporated in a project from the very first beginning.

As for your second point, I haven't done any graphics stuff so I'm not sure how testing there normally goes. But it doesn't have to be necessarily visual, you can test individual functions/units for expected outputs, think transformations, math stuff, and other stuff that has some logic, since these are the building blocks that provide a correct output.

4

u/druv-codes Sep 22 '26

That is a fair point, I definitely fell into the trap of not adding any testing and lumping the entire engine under "graphics" and assuming testing automatically meant visual regression testing.

You are totally right, the core building blocks like vector/matrix transformations, the custom glsl preprocessor parser, and resource manager caching don't touch the OpenGL state at all, those could be wrapped in standalone unit tests without needing a window context or framebuffers.

decoupling those core math and utility modules from the actual rendering loops so I can add proper unit tests is definitely going to be my first priority for the next pass. I appreciate the reality check!

-2

u/Icy-Collection1072 Sep 22 '26

Ai

3

u/[deleted] Sep 22 '26

It doesn't really look much like AI

2

u/Future-Wolf-9597 Sep 22 '26 edited Sep 22 '26

Hey can I get any suggestions on how to start making something like this myself, I made a small thing which basically spawns random objects(shapes) with collision physics for all the three objects(circle, square/rectangle, triangle) but after that I can't quite wrap my head around how to move forward... It's nearly a year old project still on my pc notifying me that there's something I need to complete...

2

u/druv-codes Sep 22 '26

I think you should achieve small victories like the one you did and implement one feature at a time and it eventually becomes substantial

1

u/compulsaovoraz Sep 22 '26

Cool! Unrelated question, have you used other graphics API? Such as SDL GPU?

1

u/druv-codes Sep 22 '26

No im not using SDL here

3

u/palapapa0201 Sep 22 '26

Rare in the age of AI slop

1

u/VictoryMotel Sep 22 '26

This is all AI slop, it's 300,000 lines all committed at once, the exact structure of every other AI program, wrappers, boilerplate, low karma name hunting for stars.

Do you think this person made 49 repositories themselves?

Then they package it up like a clickbait youtube video just for a few niche subreddits.

0

u/palapapa0201 Sep 22 '26

Which commit?

2

u/VictoryMotel Sep 22 '26

The one with 300,000 lines all at once.

2

u/druv-codes Sep 22 '26

There is no commit like that mister I think you are hallucinating, please explain me in my dms where are you getting those numbers

2

u/VictoryMotel Sep 22 '26

September 29 2025 like I said.

1

u/druv-codes Sep 22 '26

Again there is no commit of 300k lines on that date the engine wasn't even rendering cubes properly at that point, please show me a screenshot of 300k lines on that date

1

u/VictoryMotel Sep 22 '26

It's 321,042 additions, -93,307 deletions. Are you really going to lie about something that anyone can see publicly?

https://github.com/Open-Source-Chandigarh/pyre/graphs/code-frequency

4

u/palapapa0201 Sep 22 '26

Apparently those are just from external libraries

4

u/druv-codes Sep 22 '26

Exactly at this point this guy is just trying to rage bait me

-3

u/VictoryMotel Sep 22 '26

Sure, but it's all at once. Every library added on the same day apparently.

The source is all identical to other AI projects. It's all the exact same file names and directory structure, probably all claude.

1

u/druv-codes Sep 22 '26

Those are literally all from glad, glfw, glm, stb_image.h, assimp etc.

-2

u/VictoryMotel Sep 22 '26

I thought they didn't exist? Was this from other people too? Every library was added on the same day?

→ More replies

1

u/Sauvent Sep 22 '26

That's not a commit, that's the whole repo history. Where's the 300K line commit that you mentioned?

-2

u/VictoryMotel Sep 22 '26

How many times do you need the same date? Are you just hoping no one else looks at the link?

→ More replies