wglUseFontBitmaps

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();
  }
  [b]IntPtr currentHglc = gr.wglGetCurrentContext();
  IntPtr hglrc = gr.wglCreateContext(hdc);
  gr.wglMakeCurrent(hdc, hglrc); 
  GR.GDI32_SelectObject(hdc, hfont);[/b]
  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);
  }
  [b]gr.wglMakeCurrent(hdc, currentHglc);[/b]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.