WhatJac3
08-08-2010, 10:44 AM
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:
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;
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:
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:
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?
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:
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;
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:
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:
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?