PDA

View Full Version : VBO's and outline fonts



Vlasko
12-15-2004, 11:34 AM
I'm making a simple aplication and I want to use both VBO's and outline fonts.Problem is that they don't like each other :) I can use VBO's or font but using both crashes program on calling certain display list.(I don't know if this problem has been discussed yet 'cause seach on this forum doesn't work)

dorbie
12-15-2004, 09:44 PM
What do you mean use fonts?

Vlasko
12-16-2004, 12:33 AM
Using some functions slightly modified taken from Nehes lesson14.


BOOL BuildFont(const char * fontname)
{
BOOL sucess=FALSE;
HFONT font; // Windows Font ID
base = glGenLists(256); // Storage For 256 Characters
font = CreateFont(-12, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_BOLD, // Font Weight(0-1000)
FALSE, // Italic
FALSE, // Underline
FALSE, // Strikeout
ANSI_CHARSET, // Character Set Identifier
OUT_TT_PRECIS, // Output Precision
CLIP_DEFAULT_PRECIS, // Clipping Precision
ANTIALIASED_QUALITY, // Output Quality
FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch
fontname); // Font Name
if(!font)
return sucess;
SelectObject(hDC, font); // Selects The Font We Created
sucess=wglUseFontOutlines( hDC, // Select The Current DC
0, // Starting Character
255, // Number Of Display Lists To Build
base, // Starting Display Lists
0.0f, // Deviation From The True Outlines
0.05f, // Font Thickness In The Z Direction
WGL_FONT_POLYGONS, // Use Polygons, Not Lines
gmf); // Address Of Buffer To Recieve Data
return sucess;
}

void KillFont()
{
glDeleteLists(base, 256); // Delete All 256 Characters
}

void glPrint(double xrot,double yrot,double zrot,const char *fmt, ...)
{
float charlength=0; // Used To Find The Length Of The Text
unsigned char count=0;
char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments
if (fmt == NULL) // If There's No Text
return; // Do Nothing
va_start(ap, fmt); // Parses The String For Variables
count=vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap); // Results Are Stored In Text
for (unsigned int i=0;i<count;i++) // Loop To Find Text Length
{
charlength+=gmf[text[i]].gmfCellIncX; // Increase Length By Each Characters Width
}
glPushMatrix();
glRotated(xrot,1,0,0); // Rotate Text
glRotated(yrot,0,1,0);
glRotated(zrot,0,0,1);
glTranslatef(-1.0f*charlength/2,0.0f,0.0f); // Center Our Text On The Screen
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base); // Sets The Base Character to 0
glCallLists(count,GL_UNSIGNED_BYTE,text);
glPopAttrib(); // Pops The Display List Bits
glPopMatrix();
}
in glprint I've changed glCallLists to loop with glCallList so I found problematical display lists