How do you get to the point where you get a feeling of satisfaction just from writing good code?
Iterative development helps me. I'm working on a considerably big project for one person, even if it's tightly scoped. If I was basing my enjoyment on seeing it complete, I'd never get anywhere. Instead, I iterate on as small of a working codebase as possible so that I can successfully compile and run and see my changes impact the product.
Even in your example of writing a rendering framework being tedious: there's no reason for the renderer to be feature-complete before it can compile. My first step was just getting a window to show up with a black screen. Then I got a triangle to show up. Then I grabbed a pre-built model and got that to 1) show up, and then 2) show up without depth bugs. Each step came with the high of having solved a problem with code.
Granted, I had a little extra work on the first cycle getting some of the "slottable" framework elements in place, like when I wrote the code that renders with an arbitrary shader. That was a longer push, but the "hard parts" are all about discipline anyway. Now, with that part of the framework written, I can sit down and program/tweak a single shader and test it in my game rather quickly.
Someone mentioned above as well, that part of this will come with time: as you get more experience, what takes you a week currently might only take you a day or a handful of hours in the future. Experience will also let you set more appropriate milestones and goals. I generally try to aim for only what can be done by the end of the day, and it keeps me focused, productive, and amused, because I get to fully solve the bite-sized problems I've selected more often than if I was just pursuing a month-long task.
TL:DR: set shorter goals and you'll be able to enjoy the fun of solving them more often, keeping your morale up.