• Advertisement
Sign in to follow this  
  • entries
    298
  • comments
    1135
  • views
    231800

Fonts! Fonts! Fonts!

Sign in to follow this  

100 views

You font me, and I'll font you..

Today was generally a waste of time. The original plan this morning was to 'quickly' get fonts/text-drawing implemented, and then code in a simple GUI system to allow the future players to set some simple options (like Host or Client mode, or their alias) and generally look pretty.

Unfortunately, only the first part happened. The 'quick' font implementation took the majority of today. Being the spoiled little coder I am, I was under the impression that adding text drawing would be rather trivial, like it is in Direct3D via the ID3DXFont interface. Wrong! [grin]

First I went along with NeHe Lesson #13 to try to get bitmap fonts working. I really liked the idea of being able to create new font sets/styles on-the-go, rather than being bound to a premade image, like texture-mapped fonts. Rasterized fonts like bitmap fonts aren't as fast, but they sure as heck take less time to implement (when you know what you're doing). In summarization, the bitmap fonts didn't work. Odd. I was using SDL rather than the evil Win32 API like the NeHe tutorials use, so I figured that a simple call to wglGetCurrentDC() would get the device context and make life simple. Nope. Nothing rendering on the screen. The heck?

After an hour or two I caved and decided I'd try some other method to get that elusive glyph-y paradise on my screen. A few 3rd-party libraries were attempted, but they simply didn't play nice with Windows; strange makefile lingo and QT references left me feeling dumbfounded. Nuts; off to something else.

Next I went after Ravuya's RavBitmapFont class that was conveinently close to his Propane Injector files. It sounded relatively nice and easy, since it could read in AngelCode-format texture-mapped font files. Doh. Again I was struck by non-Windows fervor. Or something like that. In either case, it didn't work out. No offense to Ravuya of course. It was likely something silly on my behalf that led to my failure.

By this time I was furious. I grunted in frusteration and played Infantry, Restricted Area, and some other PC games for most of the few hours before Draffurd came over, where we drank Alexander Keith's (a flavourful beer!) and played Doom 2 on his XBox. Good times. I'm actually still semi-drunk, so excuse any illogical sentences or typos -- although I'm pretty good at preventing the latter.

Long story short:






I got it working. Turns out if you don't glDisable GL_TEXTURE_2D, rasterized bitmap fonts will never appear. Funny stuff, huh? I didn't laugh. [sad]

Anyways, this clears the path so that I can encapsulate font drawing into a class system (so multiple fonts/styles can exist), and then writing that GUI system. And then, my friend: networking!
Sign in to follow this  


7 Comments


Recommended Comments

wut? I don't understand why glDisable would have any effect on anything.

PS: I got my fonts working too. Right before my cunting IDE went emo and killed itself :[ :[ :[

Share this comment


Link to comment
Dunno why my font class didn't work out for you; I can't think of much that throws it off anymore. I tend to find bugs in my own software by virtue of being an enormous retard. [wink]

Share this comment


Link to comment
If you're using OpenGL, why don't you render fonts as textured quads? Would be probably faster too.

EDIT: To avoid sounding too negative: your work is awesomest. [grin] (well, together with a few other awesomest members)

Share this comment


Link to comment
Bah, little bugs like that is dangerous too ones health. Good to see you got it working though!

Share this comment


Link to comment
Quote:
wut? I don't understand why glDisable would have any effect on anything.


Me either, but apparently disabling it makes it work. I'm sure there's a reasonable explanation for it.

(And grats on your fonts, too :P)


Quote:
Dunno why my font class didn't work out for you; I can't think of much that throws it off anymore. I tend to find bugs in my own software by virtue of being an enormous retard.


Kept on crashing on the glu call to generate the mipmaps/texture. Not sure. :-/

Quote:
If you're using OpenGL, why don't you render fonts as textured quads? Would be probably faster too.


This is true. But like I said, I don't like being ironed-down to whatever physical bitmap images I have saved in my /Graphics directory. If I can grab any Windows font/style/size I want at runtime, I also allow users to do cool things like customize their fontset, for example. [smile]

Quote:
EDIT: To avoid sounding too negative: your work is awesomest. (well, together with a few other awesomest members)


Thanks! I've been checking out your journal too; Spineless is looking groovy. [smile]

Share this comment


Link to comment
Quote:
Original post by HopeDagger
This is true. But like I said, I don't like being ironed-down to whatever physical bitmap images I have saved in my /Graphics directory. If I can grab any Windows font/style/size I want at runtime, I also allow users to do cool things like customize their fontset, for example. [smile]


I'm actually rendering fonts to texture on the fly, so I get the best of both worlds. For static text, I'm drawing the entire string to a texture and rendering it with a single quad. For dynamic text, I'm rendering one quad per character with a texture with all the printable characters for a font. The latter method might change to something else at some point, but it works for now (it won't for Japanese or Chinese :P).

Share this comment


Link to comment
Usually it only blows up on the mipmap call if you don't have GLU (unlikely) or if the texture it's trying to load is NULL.

I'd assert that the texture is correct and ensure your loading procedure functions as intended.

Share this comment


Link to comment

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

  • Advertisement