Hi,
I’m trying to print some greek text in my opengl window, but the letters seem to be selective. I mean not all letters come up. For example I can print a lamda, but can’t print an omikron (o). Are there any examples that you know of that show how to use greek characters with opengl?
Just for reference here are my functions (taken from OpenGL Game Programming):
unsigned int CreateOutlineFont(char *fontName, int fontSize, float depth)
{
HFONT hFont; // windows font
unsigned int base;
base = glGenLists(256); // create storage for 96 characters
if (stricmp(fontName, "symbol") == 0)
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, SYMBOL_CHARSET,
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH, fontName);
}
else
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH, fontName);
}
if (!hFont)
return 0;
SelectObject(g_HDC, hFont);
wglUseFontOutlines(g_HDC, 0, 255, base, 0.0f, depth, WGL_FONT_POLYGONS, gmf);
return base;
}
void PrintString(unsigned int base, char *str)
{
float length = 0;
if ((str == NULL))
return;
// center the text
for (unsigned int loop=0;loop<(strlen(str));loop++) // find length of text
{
length+=gmf[str[loop]].gmfCellIncX; // increase length by character's width
}
glTranslatef(-length/2,0.0f,0.0f); // translate to center text
// draw the text
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
glPopAttrib();
}
// and in my render (display) function:
PrintString(listBase, "όλοι");
Another problem is that if one character that can’t be printed is in the string, the whole string doesn’t show up.
PS: The numbers in the PrintString call are actually a greek string that got messed up during posting.