Results 1 to 7 of 7

Thread: Font wglUseFontOutlines Anti-aliasing

  1. #1

    Font wglUseFontOutlines Anti-aliasing

    Hello,

    I have a problem with anti-aliasing the font that I use in my application. I have seen that more people had that problem but when trying does implementations they don't seem to work for me. When I set my anti-aliasing from my graphics card (ATI control panel) from application managed to 4x the fonts look smooth like they should. But I can't let everyone who uses my application have to change their anti aliasing settings on the graphics card. I know it can be done in the application, but I cant seem to get it work.

    Here is my current code:
    Code:
    procedure GLInit();
    begin
     glClearColor(1.0, 1.0, 1.0, 1.0); 	  // White Background
     glDisable(Gl_DEPTH_TEST);
     glEnable (GL_POLYGON_SMOOTH);
     glEnable(GL_BLEND);
     glDisable(GL_CULL_FACE);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);	
     BuildFont;
    end;
    Code:
    procedure BuildFont();
    var
     font:HFont;
    begin
     fontOffset := glGenLists (256);
     font := CreateFont(-cFontHeight, 0, 0, 0, 0, 0, 0, 0,
         ANSI_CHARSET, OUT_TT_PRECIS,
         CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
         FF_DONTCARE or DEFAULT_PITCH, cFont);
     SelectObject(DC, font);
     wglUseFontOutlines(DC, 0, 255, fontOffSet, 0.0, 0.0, WGL_FONT_POLYGONS, @gmf);
    end;
    And my pixel format:
    Code:
    procedure GLFormCreate(AHandle: HWND);
    var pfd : TPIXELFORMATDESCRIPTOR;
      pf : Integer;
    begin
     dc:=GetDC(AHandle);
    
     // PixelFormat
     pfd.nSize:=sizeof(pfd);
     pfd.nVersion:=1;
     pfd.dwFlags:=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
     pfd.iPixelType:=PFD_TYPE_RGBA;  
     pfd.cColorBits:=24;
    
     pf :=ChoosePixelFormat(dc, @pfd); 
     SetPixelFormat(dc, pf, @pfd);
    
     rc :=wglCreateContext(dc);
     wglMakeCurrent(dc,rc);  
    
     // Initialist GL environment variables
     glInit;
     GLResize();  // sets up the perspective
    end;
    If I change everything to GL_Line, so:
    Code:
    WGL_FONT_POLYGONS = WGL_FONT_LINES
    GL_POLYGON_SMOOTH = GL_LINE_SMOOTH
    GL_POLYGON_SMOOTH_HINT = GL_LINE_SMOOTH_HINT
    I get nice smooth fonts, but only the outlines of the fonts. They are not filled. Anyone has any idea what I am doing wrong?

  2. #2

    Re: Font wglUseFontOutlines Anti-aliasing

    The kind of antialiasing that you set in the GPU control panel is actually called "multisample" and requires quite a bit of code to initialize yourself.

    See this NeHe-tutorial:

    http://nehe.gamedev.net/data/lessons....asp?lesson=46
    ZGameEditor - Develop 64kb games for Windows.
    Thrust for Vectrex - ROM-file and 6809 source code.

  3. #3

    Re: Font wglUseFontOutlines Anti-aliasing

    Thanks for your reply. I have downloaded the example and had to change one thing (added the red part):

    wglGetExtString: function(hdc: HDC): PAnsiChar; stdcall;


    Now when I go debugging wglChoosePixelFormatARB returns false both times (bit either 4 and 2). My videocard (ATI control panel) gives me 8x, 4x and 2x anti-aliasing options. So I can't believe that OpenGL tells me it is not supported. Anyone has any idea what is wrong here?

    If I open the OpenGL Extension Viewer it tells met that WGL_ARB_Multisample is a correct extension.

    If I list the pixel formats it tell me for instance that pixel format 30 has:
    WGL_DOUBLE_BUFFER_ARB = TRUE
    WG_ACCELERATION_ARB = TRUE
    WGL_PIXEL_TYPE_ARB = 0
    WGL_SAMPLES_ARB = 8

    Any idea why it doesn't work? Even if I use the options from a correct pixelformat (nr 14 accoring to OpenGL Extensions Viewer), I still get a false as return value.

  4. #4

    Re: Font wglUseFontOutlines Anti-aliasing

    Or does anyone know how to list all pixelformats? If I choose one myself from OpenGL Extensions Viewer with Anti-aliasing, it works perfect. So if I could list all options I would be able to pick the most appropriate, since the example from NeHe does not work.

  5. #5

    Re: Font wglUseFontOutlines Anti-aliasing

    Did you purposefully disable anti-aliasing from graphics card settings or are they set on "application-control"? Those settings can lock anything from using it... ofc depends on manufacturer etc.

  6. #6

    Re: Font wglUseFontOutlines Anti-aliasing

    It is set on application-control.

    I am now iterating through the pixelformats with:
    Code:
     K := DescribePixelFormat(dc, 1, L , pfd);
     while K do
     begin
      K := DescribePixelFormat(dc, J, L , pfd);
      J := J + 1;
     end;
    Now I only need to find a way to check the value of WGL_SAMPLES_ARB from pfd to find the best possible pixelformat.

  7. #7

    Re: Font wglUseFontOutlines Anti-aliasing

    I fixed the NeHe example. It has one problem. This is what should be done.

    In ARB_multisample add:
    Code:
    type
     TGLLongArray = array[0..21] of GLInt;
     PGLLongArray = ^TGLLongArray;
    change wglChoosePixelFormatARB into:
    Code:
     wglChoosePixelFormatARB: function(hdc: HDC; piAttribIList: PGLLongArray; pfAttribFList: PGLfloat; nMaxFormats: GLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; stdcall;
    Add after the iAttributes[21] := 0;
    Code:
    tmp := @iAttributes;
    Change valid := wglChoosePixelFormatARB into
    Code:
    valid := wglChoosePixelFormatARB(h_dc,tmp,@fattributes,1,@pixelFormat,@numFormats);
    Now the example works. Enjoy!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •