4 Hugues Ross - Blog: DFEngine Update 2
Hugues Ross

5/17/14

DFEngine Update 2

Changelog:

  • Added Text Rendering, using FreeType
  • Reworked some of the structure, primarily with components
  • Added some initial Lua scripting features
  • Made some minor changes that should speed things up down the line

Text Rendering:

So, the font stuff's done. Now that I'm using the FreeType library to load fonts, the visual quality of the text has improved dramatically. Instead of the previous sprite fonts(which I may add support for at some point, but not now) which had to be drawn and generally looked pretty bad, I can now use any font that you'd otherwise see used in most applications. These fonts have several massive advantages: First, they're scalable. Once one's been made, I can set it to be used at any size. Second, they are properly aligned. Most sprite font systems don't account well for the sizes and shapes of letters, and the resulting text looks blocky and strange. It's also difficult to deal with letters of different heights, especially those that need to be placed lower than others. FreeType gives you all the information needed to align your letters nicely. Lastly, it's much simpler to read these fonts in and keep track of them. Even if I decide to make my own font files, they'll be made using information gotten from FreeType. I can edit the base font normally, and I won't need to keep track of anything else.

To be honest, the actual process of getting FreeType into a program is pretty boring. The library handles most of the really interesting things behind the scenes. That said, I should leave a word of warning: Most of the tutorials I found for using FreeType with OpenGL were outdated and/or useless. If you want to use the library, you're better off looking through the documentation to get an understanding of how it works, then using that as reference. There's a nice tutorial there to help walk you through the basics of setting up and using FreeType in your application, which is what I used.

Lua:

If you've seen how AMAZE operates under the hood, you'll very quickly find that the scripting is very rudimentary. I'd originally considered using lua, but I eventually decided not to until later. Of course, I never expected things to go as they did, and the scripting stayed as it was. Finally, I can fix that. In order to do so, I had to rearrange quite a bit of code, mostly dealing with components. Components belonging to one entity are now held together in an entity class, and systems hold less power. Now, most of the 'meat' of an entities behavior will be defined in lua scripts that the entity can call. Systems will handle more complex things, such as collisions, timers, and other processes that require knowledge of the game's 'big picture.' Anyway, one of the biggest upsides to using lua will be that the syntax of scripts can be much more complex, and more information can be obtained in these scripts. It'll also make the engine code simpler and cleaner. Overall, it means that I can do fancier things than before, and with it'll be easier too! Of course, lua integration is still ongoing, so for the moment I can't do much more than spawn a couple of basic test objects when the game starts. I did, however, make a nice little FPS counter using lua. I'll probably end up using lua scripts to handle some more basic things like setting up the UI, but I haven't decided for certain yet.

No comments: