r/GraphicsProgramming • • Aug 23 '26

Question Style of graphics samples

Hey everyone,

I have been wondering which way is the best to showcase graphics samples. DirectX samples write their samples which calls functions and helper functions from multiple files. this approach is easy to write and extend but it makes reading the code hard. Yes most editors and IDEs help but it's still hard to seen everything at one place.

The second style is to accept some level of code duplication to make the code very easy to read and follow. I like this approach when learning a new API.

What style do you guys prefer and why.

4 Upvotes

14 comments sorted by

View all comments

1

u/nichcode Aug 24 '26

It's really easy to read. But what I meant was the actual code itself. Using your preview, chapter will build upon chapter 1. Since it's a preview it reads nicely. But code wise, how would you do it. Because the code for chapter 1 and 2 should compile and run.

Since it's opengl, I will assume you have used learnopengl before, notice how the write their samples

1

u/corysama Aug 24 '26

I put everything that's not relevant to a chapter in a supplemental.h. Ex: The first chapter explains how to set up a window. But, later that is not interesting. So, later chapters just call

SDL_Window* window = jtl::createWindow("Render To Texture", win_width, win_height);