I realized I was going to talk about my goals, but I didn't really set them. Or well, I probably did, but I forgot about them once they were achieved. I'll write them down next time.
I spent a pretty amazing time this weekend hammering out some things on the game. First, I had fixed some pernicious bugs that were plaguing my graphics system. I can now appropriately texture things (with different! gasp textures). The issue seemed wholly unrelated, and I think is another problem with the OpenGL implementation (which is a software renderer, I discovered. Although I'm not sure why that's surprising, since I'm running on an emulator anyway). It turns out that the GLES spec specifies that the GL State should remain completely unchanged if an error occurs in a function, as if the call was never called at all (there's an exception for out of memory errors, which are allowed to totally break everything completely). Well, turns out one of my calls was producing an error, and fixing that was a necessary, though not sufficient, part of the solution. It turns out that two of the parameters you pass to the function to glTexImage2D (the function to configure 2D Textures) need to be the same, and I was accidentally passing in different values - I had written some code to derive the second value based on the texture as loaded from the file, but the first value was old code from where I was assuming everything was the same. I don't really remember what else I had to do to get it fixed, but it did eventually happen. Here's Proof:
By Sunday, I was growing pretty tired of working with C++, so I dove into the much friendlier C# and whipped up a pretty awesome tool. I now have a nice command-line utility and a bash script (I was apparently not content to go completely without suffering) that will take a directory, compress it to a new file with zlib, and then combine those files into a custom file format. It's essentially gzip + tar (or just a .zip archive, on Windows), but less general, and probably better compression since I throw away directory information. Also I didn't have to look up the tar format and could roll my own pretty easily. The tool also outputs a header file for inclusion in C/C++ that creates identifiers for the assets based on where they are in the filesystem. So, after running bpack on /assets, I can refer to the file at /assets/foo/bar.tga as BPKID_FOO_BAR_TGA. You didn't think I was completely throwing away the directory structure, did you? In the header it's just #defined to a unique integer. The idea being I can write a module (some of which I've written today) that will associate the number with an offset in the archive, and then read it, un-zlib it, and return the data when it's requested, and that throughout the rest of the game, I can just ask for assets by their BPKIDs.
Speaking of the amount of work I've gotten done today, it feels like virtually nothing. And I keep running up across questions I've been putting off. Things l like "where should the memory for this be allocated?" or "Which module should be responsible for x" or "On an error, should I halt here? Throw up a return code? Keep going if I'm in a relatively recoverable state?" I should really whip up a technical design document which begins to address these things.
I started on something like that once, but it got hard to think about and so turned into a Coding style document. I don't need a coding style document, it's just me! (Although it probably wouldn't hurt, since I do tend to change my style slightly from day to day because I think something seems a little better or worse for the situation at hand--e.g. sometimes int Value() feels nicer to me than int GetValue(). It would definitely behoove me to stick to something logical).
So, there you have it - my goal for tomorrow is to come up with a draft of the document which will describe what I'm trying to accomplish with each module at nice medium-depth level, so that I won't have to worry too hard about making those decisions while I'm coding, which will hopefully let me just code, and not have to pull my head out and start thinking about the big picture. I'll have a postcard of the big picture next to me so I can just do what it says :)

Leave a comment