Sign in to follow this  
  • entries
  • comments
  • views

Font Rendering

Sign in to follow this  


I decided to skip the 'draw quads' stuff today and instead attack the font rendering code instead.

The problem is, as I started writing it, I had no real idea how I wanted todo it; you see the font consists of two components, the font texture(s) and meta-data to describe where in the texture each character is.

The question is, how do we sanely load this data, hand off the image data to the render as a texture and parse the meta-data.

I think, in the end, I'm going to end up linking GTL directly into Bonsai and having it do all the texture handling and loading under the hood. Atm the Bonsai texture functions take a pointer to the data (via the lightuserdata type) and hand it off to OpenGL, so when you load a texture you first of all have to get a GTL object (or another loader which does the job), extract the information and then call the Bonsai graphics system's 'createTexture' function.

Instead, I might change it so that 'createTexture' becomes 'loadTexture' and it does all the hardwork for you.

Based on that a 'texture' object will come into existance to deal with the resulting handle. It'll basically let me get at the width and height of the texture object as well as perform a delete when the object is collected by the GC. And, of course, it'll hold the texture id.

Going back to font rendering, the 'LoadFont' function is going to need to return either a table with all the data in or two values of the character set details and the texture list. The first option is the most logical of course as the character set data and the textures are bound together.

Internally the text rendering function will use drawQuads to render everything, or maybe a function which is slaved to both drawQuads and the text rendering function; lets see what is more logical once we get there (to use the 'drawQuads' function directly I would have to pass parameters via the Lua stack and then pop them off again, which could be consider a waste of time).
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now