Thursday, August 12, 2010

Week Five / Day Three

This week seems to be rolling right along quite well, as today played out just about as smoothly as the last two days. Today's big goal was to get the basics of the level loader working, and to do that proper I had to implement some form of text rendering. Now, OpenGL has no built in way to render text, so there are a few ways of going about it. One of the tutorials I read through described using a glyph scripting language to 'build' fonts out of primitives. While this brings a lot of versatility in terms of fonts, the process was quite complicated and a bit more than I needed for my game (I also couldn't get all the different python libraries required installed correctly). The other method is to create a character map as a texture atlas and then pull individual characters out with the texture coordinates. This is the method I went with, and it works great. I haven't had a good challenge in a while where I had to implement an algorithm that took the place of brute force conditionals, and this was exactly what was needed for the character grabber. A 'slider' big enough to fit one character is moved along the texture based on the ascii values of the character. You insert a vector< string >, and each string is printed with a return at the end. The strings are parsed by character, each rendered from the coordinates found given the ascii value used by the slider. Unfortunately the map is rendered with white characters on a transparent background, so it won't show up here.

I also corrected the texture issue. I'm using a different method for loading pngs now that also allows me to load pvrs, so I've been able to mess around with compressed textures as well. They looked quite lossy, and the mipmaps were terrible, but in game you almost can't notice a difference. I still have a problem with updating my pngs in gimp and then loading them into the engine. After being manipulated a few times, the texture fails to load. I've been working around it for the time being, but hopefully I can get it straightened out.

I also got the texture color changing working. Turns out lighting has to be disabled or else the color is completely ignored. I'm hoping this just turns out to be a quirk with how I currently have lighting setup. The good thing is I can now adjust the alpha of a texture, which allows me to fade textures in and out. With this, I can now smoothly transition between screens and such, resulting in a much more professional 'feel' in the interface.

Lastly, once I had text working, I started on the implementation of the level selection. It isn't working perfectly just yet, as I can see the level names but it doesn't load anything other than the first, but I'm pretty sure it'll be a quick fix. I believe that's most of what I got done today. Things are rolling along well now, and I hope I can continue down the designing and tweaking path for a little while. In the mean time, here are some shots of where I got today. Names blocked out to protect the innocent:

No comments:

Post a Comment