Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

A scene by design

SKETCHBOOK / 04 The composition desk · 2-week chapter

Page 1 of 6: Compose a world from values

One scene, no format detour

Compose a world from values

A scene is a collection of values describing a camera, geometry, colors, and light. In this course you construct that description directly in C++23. A text configuration format is not required to learn rendering, and adding one would introduce a second problem before the image problem is understood.

The native demo_scene() returns an owned Scene. Its string and vector members retain their own data; no result points into a temporary input buffer. Make a local copy, change a sphere or camera value, and pass that candidate to validation. The reference composition is a starting point, not a portfolio result you have already authored.

Keep representation separate from action. Constructing a Scene should not open an output file or create a graphics context. That gives you a small, repeatable object to inspect in a debugger and reuse in tests.

TRY IT IN YOUR STUDIO

Create your own scene function with one deliberate composition change. Draw which object owns the sphere vector and the returned image bytes.

C.20Compose ordinary owning values using the rule of zero.
From the page to your own work

Your studio assignment.

Build a typed scene in C++ and make unsupported states fail at a visible boundary.

A finish line you can see

Your own typed scene variation, one accepted boundary test, one rejected boundary test, and a written validation contract.

  1. Change the demo scene through typed values; no configuration parser is required.
  2. Test an accepted dimension or radius boundary and its rejected neighbor.
  3. Show that render validates caller-constructed scenes too.
  4. Explain one arithmetic or non-finite-value failure that the member types alone cannot prevent.
Keep the evidence in your weekly notebook ↗
Explain it like an engineer

Try answering aloud before opening the review notes. Use your own implementation as evidence.

Why does a Scene with correctly typed fields still need validation?
  • Types do not establish positive dimensions, finite vectors, or cross-field budgets.
  • Check factors before multiplying dimensions or work counts.
  • Return a complete result or error without publishing a partial change.

These prompts support practice; they are not an automatic assessment of your work.

A small creative variation ↗

Create a second scene function with a different composition while retaining the same validated domain.

Optional. Save it for later if this chapter already feels full.

Coming back after a break? ↩

Call demo_scene(), change one sphere color, and render once. Then run just one validation test.

Books & principles behind this study +

Original Parallax explanations and assignments, with these works for further reading.

YOUR MARGIN NOTES

Leave yourself a good question.

What changed your mind? What would you try next?

Notes are private to this browser and saved as you write.

A CHECKPOINT, NOT A SCORE

Can you explain the idea and try the exercise yourself?

Completion records your own assessment. It does not compile or test your C++.
Companion source 9 files