• 10
• 10
• 12
• 12
• 14
• entries
503
1888
• views
334595

Text

165 views

So, as the mighty board of development progress shows, I am working on the font engine.

Thankfully we implemented a rather nice font engine in Flare, and it will be coming over to S3.

The top-level API exposes a method to create a Typeface(an alias an image and widths file pair)

once loaded a typeface is immutable undestroyable for the lifetime of the engine session, any attempt to load a typeface with the same alias of an existing typeface will be ignored and the existing typeface will be unchanged.

these restrictions are for performance sake.

when a part of the engine wants to some drawing, it creates a Font object.

a font object consists of:

A color
A size
A typeface reference

The creation of the font object uses the typeface alias to resolve the typeface reference.

since the engine is only accessable through the script interface, the script api defines functions for setting certain fonts to certain areas of the engine, such as:

setInfoTextFont(...)
setDialogueFont(...)

as each one of these systems are processed they set their own fonts before they draw their text.

on the engine side when a font is set it's reference is held and used for every call to:

renderText(string,l,t,r,b,flags)

the rendering engine supports left,hcenter,right alignment and supports word wrap and character clipping.

text in the s3 engine is primarily used for some radial menu items, info text (stuff your mouse is over) and Dialogue, in many cases the engine can override parts of a font, for instance:

if no desired dialogue color is set for a character, then it will use the default color (narrator color) otherwise the speaking character's color is set to it.

Text is rendered in batches of fonts, a TextBatch object references the font, and keeps a copy of the text to be rendered, the font rendering engine then converts the text and the font into a serries of quads which are added to a dynamic vertex buffer.

an important restriction is that no more than 256 characters of text per-font, given the text usages in S3 this is not a big deal.

the restriction allows for easy use of indexing, a 256*6 element 16 bit index buffer is used to reference the vertex buffer, which can now be much smaller, and potentially utilize the vertex cache.

the basic rendering loop looks somthing like this

set vertex buffer
set index buffer
baseIndex = 0
for each TextBatch
set font texture
set font color
draw indexed primitive baseIndex,all of the primitives in this batch
baseIndex+=number of indexes we drew
end
set null index buffer
set null vertex buffer

Out of random curiosity, do you have other task-tracking solutions in place? I've gotten spoiled with a complete task management and delegation system that I wrote for my day job, and I'm curious if anyone else is using similar tools in the indie scene.

I've come across a few teams that use various parts of Microsoft Office to track progress and work items in indie projects. I've not messed with it myself, but "Microsoft Project" kept getting mentioned [smile]

Thinking of that, I have every office 2003 progam installed - I might go play.

Anyway, EDI, have you given any thought to temporal caching of text? Performance wise it was the biggest winner for the engine I wrote. Even at a low 30hz rendering loop, the text only gets updated every 3-4 frames at most when being edited by the user.

Jack

Currently we dont have an internal task tracking system, it would be nice but I haven't put much effort into it, note-pad seems to work fine for most things =D

As for temporal caching of text, that is not a bad Idea, though the implementation sounds like it might be weird.

as a 2D developer I come from the concept of, 'if you dont draw it, it does not exist'

however in the realm of 3D realm you cant just 'draw somthing' you are required to set up the source data for it, which is expensive; doing that each frame if you don't have to is not good.

however the question at hand is 'how do I know I dont have to?'

it is conceivable that I can have a vertex and index buffer large enough to contain all of the text you would ever need to see in a scene. (though any change to a single piece of text would require the restructuring of the VB)

so, imagining a GameText object, wherein you could add text to the scene, which is created and shown forever is easy to implement.

however removing that text is not exactly trivial, each piece of text entered would need to have an alias or some other way of referencing it, so that it could be turned off.

I would like to hear more on this if anyone cares to explain =)

Quote:
 I would like to hear more on this if anyone cares to explain

Quote:
 the question at hand is 'how do I know I dont have to?'

One way of looking at it (which isn't always accurate) is that if you assume your caching system does the same work you'd be doing on a per-frame basis, then calling that caching system every frame (same as before) should yield no worse performance than you already have. However, as soon as it does start to work (i.e. you get a sequence where the code only updates every second like a FPS counter) you'll see the benefits [smile]

hth
Jack

Quote:
 So, as the mighty board of development progress shows, I am working on the font engine.

Actually, it only shows that if you understand what your text colors mean. Your map needs a legend.

As far as project management goes, my copy of MS Project ended up going for $109 (yay me). A cheaper alternative is Turbo Project. I tried it a long time ago, and it was pretty capable. Basically a cheaper MS Project knockoff.$45 for the express version is pretty good.

Of course if you've got PHP (and you should), you could go with something online like this or this.

I recommend Project. I also recommend FogBugz, Excel, Access databases, a wiki, and Notepad.

I too was a member of the Notepad Is Fine camp, for many years. Then, for some reason I'm still not entirely clear on, I built myself a complete task management system (complete enough for my personal needs). I will never go back, and I'd highly recommend taking the time to build (or at least buy) one. It's one of those things that doesn't seem all that useful from one perspective, but once you've gotten it, it saves a monumental amount of time and confusion.

Plus, working on a project with more than one person and not using a task coordination system is just begging for trouble. So many communication and collaboration problems simply go away that it isn't even funny.

Worst case, sacrifice a couple of weekends and set up something formal, just for the heck of it. Make sure it is easy to use and captures the bulk of what you need it to do. If the unthinkably bad happens, you lose a weekend or two. In any other scenario, you win [smile]

I also hear basecamp is pretty good (http://www.basecamphq.com/), but I've never tried it. Fogbugz (http://www.fogcreek.com/fogbugz) though is one of the most simple, yet powerful, project management tools I've used. And in conjunction with Project (or perhaps the one Hattan mentioned) you have a pretty good idea where you're at, where you're going, and a decent estimate of how long it's going to take you to get there.

That's quite the todo list you have there.