PDA

View Full Version : wglUseFontBitmaps



atlasdynamics
07-07-2011, 11:11 AM
I can only create the bitmap fonts using wglUseFontBitmaps when I create a new context. If I use the existing context the wglUseFontBitmaps function fails. Any help would be much appreciated, thx.



bitmapFontOpenGLDisplayListBase = gr.glGenLists(256);

IntPtr hfont = new IntPtr();
System.Drawing.Font font = null;


if (true == useGDICreateFontDirectly)
{
hfont =
GR.GDI32_CreateFont
(
fontHeight, // height ; negative means CHARACTER height; positive means CELL height
fontWidth, // width
0, // escapement
Orientation, // orientation
GR.FW_NORMAL, // weight
italic,
underline,
strikeout,
GR.ANSI_CHARSET, // char set
GR.OUT_TT_PRECIS, // output precision
GR.CLIP_DEFAULT_PRECIS, // clip precision
GR.ANTIALIASED_QUALITY, // quality
GR.FF_DONTCARE | GR.DEFAULT_PITCH, // pitch and family
fontName // font name
);
}
else
{
font =
new System.Drawing.Font
(
fontName, // family: "Verdana", "Arial", "Courier New", "Symbol", "Wingdings", "Wingdings 3"
fontHeight, //(float)fontCellHeightInPoints, // emSize: Font size (see 4th parameter for units)
System.Drawing.FontStyle.Regular, // style
System.Drawing.GraphicsUnit.Point, // unit
((System.Byte)(0)) // GDI character set
);

hfont = font.ToHfont();
}

IntPtr currentHglc = gr.wglGetCurrentContext();
IntPtr hglrc = gr.wglCreateContext(hdc);
gr.wglMakeCurrent(hdc, hglrc);
GR.GDI32_SelectObject(hdc, hfont);



int result = 0;

result =
gr.wglUseFontBitmapsA // Use wglUseFontBitmapsW() instead if this doesn't work!!!
(
hdc,
0,
255,
bitmapFontOpenGLDisplayListBase
);

if (0 == result)
{
String message = "wglUseFontBitmaps() error";
MessageBox.Show(null, message, "Error", MessageBoxButtons.OK);
}
gr.wglMakeCurrent(hdc, currentHglc);