Original Post
Well, I'm about to my wit's end on this. It's pretty much based off NeHe's tutorial and some other sources. Using display lists for fonts is the only way I've ever seen it done, and it's not working out very well for me, at the moment. Basically, I have it set up so I can output text to the screen like a std::cout call. Like: font << "Hello thar! " << 123 << someObjectWhosGotOperatorsOverloadedToHandleThis; Here is what I think is the relevant code: That is the font printing method. I know I'm getting the string right, because when I call std::cout << s; it shows whatever I send to the function, it's just the rendering part that isn't working at all, and I don't know why. I've used display lists to draw fonts tons of times and it's always worked for me. Oh, by the way, I'm using outline fonts. Here is my BuildFont() function if you want to look at that: I don't know what else to show you guys, but if you need to see more code just ask and I'll post it. Thanks a lot for any help. UPDATE: Ok, I didn't notice before, but it actually *is* rendering. It's rendering it VERY small up in the top. It's not rendering it at size 48 like I want it to, it's rendering it smaller than 1 pixel, it's also upside down. (How do I know if it's upside down if it's smaller than a pixel you ask? I changed the projection so it would be way more zoomed in and I could see) It also keeps rendering it over and over in one long line (Like, instead of just saying "Hello!" it says "Hello!Hello!Hello!Hello!"). UPDATE THE SECOND: Fixed one problem, the position problem. Apparently glRasterPos doesn't work with outline fonts. Using glTranslate3f puts it in the right position. UPDATE THE THIRD: Solved the upside down-ity problem, now all that's left is the size problem and the drawing over and over problem. UPDATE THE FOURTH: Ok, using glScale I came up with a crappy hack solution to the size problem, now all that's left is the annoying problem where it keeps writing in a really long line, instead of writing in the same place it did during the previous loop. [Edited by - Samith on December 30, 2004 5:10:51 PM]
template<typename T> CFont& operator<<(T const& t) {
oss << t;
s = oss.str();
std::cout << s;
glPushMatrix();
glLoadIdentity();
glColor4f(r, g, b, a);
glTranslatef(0.0f, 0.0f, 1.0f); // translate one unit into the screen
glRasterPos2f(xScreen + xMod, yScreen);
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(s.length(), GL_UNSIGNED_BYTE, s.c_str());
glPopAttrib();
glPopMatrix();
for(int i = 0; i < s.length(); i++) {
xMod += gmf[s].gmfCellIncX;
}
return *this;
}
void CFont::BuildFont(const char* fontname, int size)
{
HFONT font;
HDC hDC;
base = glGenLists(256);
hDC = wglGetCurrentDC();
font = CreateFont(-size,
0,
0,
0,
FW_NORMAL,
false,
false,
false,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
FF_DONTCARE|DEFAULT_PITCH,
fontname);
SelectObject(hDC, font);
wglUseFontOutlines(hDC,
0,
255,
base,
0.0f,
0.2f,
WGL_FONT_POLYGONS,
gmf);
}