{"id":3733,"date":"2022-04-17T12:37:58","date_gmt":"2022-04-17T16:37:58","guid":{"rendered":"https:\/\/shiningrocksoftware.com\/?p=3733"},"modified":"2022-04-17T12:37:58","modified_gmt":"2022-04-17T16:37:58","slug":"code-rot","status":"publish","type":"post","link":"https:\/\/shiningrocksoftware.com\/2022-04-17-code-rot\/","title":{"rendered":"Code Rot"},"content":{"rendered":"
Code rot is really a thing. If you've got some source code and you leave it along for too long, it stops working properly. It doesn't matter that the source hasn't actually changed. Really!<\/p>\n
Maybe you've made major changes to some parts of your code, not realizing that other parts were dependent on it. Maybe you're calling that code in a new way or with new parameters. Maybe you changed a compiler option that causes problems. It could be almost anything. Either way when you start using that code again, it takes some work to get it running properly again.<\/p>\n
It happened to me this week. I'm on the cusp of changing how some things are rendered in game, and so I need to add a few features to the graphics part of my engine. At the moment I've got two ways to output graphics. I like coding with DirectX, but I also support OpenGL for multi-platform purposes. So when I make changes to the really low level rendering code, I have to write it for each API.<\/p>\n
I haven't actually used the OpenGL output in a while. And why would I? The graphics code has been stable for a long time, what I expect to get rendered is what I see, and there's so many other things to work on that how pixels end up on the screen is far and away. There's pretty much no reason for me to go into settings and change it. But I switched to the OpenGL output to start work on my new features and... ugh, the output is ugly.<\/p>\n
So I start fixing things. And fixing one thing shows another problem, and so on, and so on... This is how the latter part of my week went.<\/p>\n
Why? Why!? Other than array textures, I haven't added any major features dealing with graphics since I initially wrote it!<\/p>\n
The problem is that I've been merrily adding things over the last few years, and the OpenGL renderer hasn't been used. All the rendering features I wanted were in the code. But the ways they were getting used was different from when I wrote it initially. I also never shipped a game with the GL code, so a lot of the code paths that weren't followed or tested heavily had issues. Blah.<\/p>\n
I know, I know, you think I should have some sort of unit testing for my graphics output.<\/p>\n
Anyway, spent the last three days fixing things. Graphics coding is notoriously hard to debug. Difficult to find issues, but pretty much each one of the problems above was a one or two line code fix. But now things look nice, and in fact I can't tell which rendering path is being used now without checking settings.<\/p>\n
I'm sure I have more of this code rot in the code. I haven't been using certain systems like achievements or audio with this new project yet, so I'm willing to bet as soon as I start, there will be more junk to cut out and clean.<\/p>\n
What was it I was going to add again before I started fixing things?<\/p>\n","protected":false},"excerpt":{"rendered":"
Code rot is really a thing. If you've got some source code and you leave it along for too long, it stops working properly. It doesn't matter that the source hasn't actually changed. Really! Maybe you've made major changes to some parts of your code, not realizing that other parts were dependent on it. Maybe […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/posts\/3733"}],"collection":[{"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/comments?post=3733"}],"version-history":[{"count":7,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/posts\/3733\/revisions"}],"predecessor-version":[{"id":3742,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/posts\/3733\/revisions\/3742"}],"wp:attachment":[{"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/media?parent=3733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/categories?post=3733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shiningrocksoftware.com\/wp-json\/wp\/v2\/tags?post=3733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}