Friday, September 9, 2011

The Rewrite To End All Rewrites

So I've had this huge problem for the past 5 years or so that I've been writing programs where I just can't close the deal on a piece of code or subsystem to save my life. Whenever I spend a significant amount of time working on a feature, I inevitably go back almost immediately to rewrite the entire thing convinced that it just wasn't right!. This was much more of a problem prior to entering college, when my programming work was comprised of nothing but schedule-less projects that went on for an eternity. Even after school and eventually life made me realize that I couldn't afford to rewrite things 500 times however I still feel that the problem as a whole persists. I've got a few decent projects under my belt (namely my ray-marcher VolTex I've mentioned before or another project from last year that I'm sure I'll write about eventually) and at my current job I can get things done ahead of time, but all in all I think that when the schedule and the project is left entirely up to me I fail to deliver at any reasonable pace due to my previously mentioned hindrance.



Coming to a head

As a result of all of these rewrites, over the years I've accumulated quite a bit of dead code that, if properly utilized, could be extremely useful. One of the things that's always held me back from a lot of interesting ideas and projects is the boiler-plate code that is necessary to get a project in my language of choice (C++) off the ground. Much of the rewritten (and rewritten....and rewritten...and rewritten...) code in my dead projects is this exact type, and so my latest undertaking is the culmination of all of these rewrites into one solid framework that I can use to prototype ideas and hopefully develop small games with. What's this project called? Well, the Rewrite Engine of course...


Progress so far

So far I've integrated probably half to two-thirds of the code I've had lying around in the scattered remains of failed projects. Progress on that front has been less-than-quick, but nonetheless steady, as I feel that the easiest way to truly gauge what should be added is to build the framework and keep an eye out for places where I could reuse existing code. This has worked so far, and it's also meant that I've had an opportunity to work on some things I hadn't before, namely advanced OpenGL, while I'm busy not reinventing my own wheels for the first time.

Sadly, not a whole lot of this stuff so far is interesting. I've got a logging system, XML reading / writing, string utilities, file utilities, stream utilities, timing, messaging, configuration variables, semi-implemented OS abstractions and a dozen or so other features I can't remember off the top of my head. That's what I've integrated more or less from existing code bases I had laying around. The biggest (interesting) development has been in the OpenGL 3.X rendering API I've been extending that I started during a Computer Graphics course at my college. I call it MyGL, and I'm developing it more heavily than the other areas currently and most likely into the foreseeable future.

Here are some shots of what it can do so far, keep in mind the entire thing is still in it's infant stages.





















Future outlook

I'm still relatively new to OpenGL. My first project with it was a little less than a year ago and I've been learning steadily since that point. I hope to use this new engine and the projects I take on because of it as stepping stones toward fully learning and comprehending the monster. Next time I hope to have something more to show, perhaps some progress on the shaders front or some fancy new model format loading (OBJ sucks...), but at the very least it'll be a lot more short 'n sweet than this monolithic post has been.

Last but not least, I've had the project on GitHub since day one, just as a personal record for myself. Those interested can check it out below.

The Rewrite Engine

Note: If I haven't made it clear somehow above, the code in this is a learning experience and I have no doubts that the OpenGL code especially will make those who know the API better than myself truly cringe. Also there is nearly no notion of coding standard throughout, as much of this code was written at different times in my life as I developed as a programmer...maybe I'll rewrite it someday... </excuse>

No comments:

Post a Comment