Hello,
I've been going through the NeHE Lessons and I am now on Lesson 13. I can get it to run fine but when I try to change the size of the font It will not get smaller or bigger... I've looked at the documentation on msdn and searched google on the CreateFont function and i'm getting no luck... I'm looking for a pointer as to why my text won't change size.. Here is the code I am using...
GLvoid BuildFont(bool outline) {
HFONT font;
HFONT oldFont;
// int PointSize = 0;
// int nHeight = -MulDiv(PointSize, GetDeviceCaps(_pGame->GetHDC(),
// LOGPIXELSY), 72);
if (outline == true) { // Comic Sans MS
MessageBox(NULL, "Outline", "Outline", MB_OK);
base = glGenLists(256);
font = CreateFont(-12,0,0,0,FW_BOLD,false,false,false,ANSI_CHARSET,
OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH,"Comic Sans MS");
}
else {
MessageBox(NULL, "Bitmap", "Bitmap", MB_OK);
base = glGenLists(96);
font = CreateFont(-24,0,0,0,FW_BOLD,false,false,false,ANSI_CHARSET,
OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH,"Courier New");
}
oldFont = (HFONT)SelectObject(_pGame->GetHDC(),font);
if (outline == true) {
MessageBox(NULL, "Outline", "Outline", MB_OK);
wglUseFontOutlines(_pGame->GetHDC(),0,255,base,0.0f,0.2f,
WGL_FONT_POLYGONS,gmf);
}
else {
MessageBox(NULL, "Bitmap", "Bitmap", MB_OK);
wglUseFontBitmaps(_pGame->GetHDC(),32,96,base);
}
SelectObject(_pGame->GetHDC(),oldFont);
DeleteObject(font);
}
GLvoid glPrint(bool outline, const char *fmt, ...) {
float lenght = 0;
char text[256];
va_list ap;
if (fmt == NULL) {
return;
}
va_start(ap,fmt);
vsprintf(text,fmt,ap);
va_end(ap);
for (unsigned int loop = 0; loop < (strlen(text)); loop++) {
lenght += gmf[text[loop]].gmfCellIncX;
}
glTranslatef(-lenght/2,0.0f,0.0f);
glPushAttrib(GL_LIST_BIT);
if (outline) {
glListBase(base);
}
else {
glListBase(base - 32);
}
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
}
int DrawGLScene(GLvoid) { // Heres where we do ALL the drawing
// Clear the screen and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
DrawMap();
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glTranslatef(0.0f,0.0f,-1.5f);
glColor3f(1.0f,1.0f,0.0f);
glPrint(true, "Lotas - %3.2f", rot/50);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,1.0f);
rot += 0.1f;
return true; // Everything went OK
}
int initGL(GLvoid) { // All setup for openGL goes here
// Start Of User Initialization
if (!LoadBitmap("Data/wall.bmp", texture[0], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, 1)) // Load The Bitmap
return FALSE;
if (!LoadBitmap("Data/floor.bmp", texture[1], GL_LINEAR, GL_LINEAR, 0)) // Load The Bitmap
return FALSE;
if (!LoadBitmap("Data/ceiling.bmp", texture[2], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, 1)) // Load The Bitmap
return FALSE;
if (!LoadBitmap("Data/lobManga5.bmp", texture[3], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, 1)) // Load The Bitmap
return FALSE;
if (!LoadBitmap("Data/door1.bmp", texture[4], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, 1)) // Load The Bitmap
return FALSE;
if (!LoadBitmap("Data/Glass.bmp", texture[5], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, 1)) // Load The Bitmap
return FALSE;
// glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glEnable(GL_TEXTURE_2D); // Enable Texture mapping
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glClearColor(0.0f,0.0f,0.0f,0.0f); // Black Background
glClearDepth(1.0f); // Depth Buffer setup
glDepthFunc(GL_LEQUAL); // The type of Depth Test to do
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glShadeModel(GL_SMOOTH); // Enable smooth shading
// Really nice perspective calculations
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_LIGHT0);
BuildFont(true);
SetupWorld();
return true; // Initialization went OK
}
I'm trying to add some text to a map I created. I want to move the text with the camera but first I need to get it to be much smaller...
If you need more code just let me know :)
Thanks in advance for the help :)
*** Why'd you run away? ****** Don't you like my... style***