|
This post was updated on .
I'm trying to use new TextRegionUtil to render a simple text to screen. I'm using GL3 on Mac OS X, so I cannot use GL2 backward compatibility and old TextRenderer, that work very well.
This is what I do:
Font font;
int[] sampleCount;
int renderModes;
RenderState renderState;
RegionRenderer renderer;
TextRegionUtil textRegionUtil;
renderModes = Region.DEFAULT_TWO_PASS_TEXTURE_UNIT;
renderState = RenderState.createRenderState(SVertex.factory());
renderer = RegionRenderer.create(renderState, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
textRegionUtil = new TextRegionUtil(renderModes);
Font font = FontFactory.get(new File("fonts/ApexNew-Book.ttf"));
sampleCount = new int[] { 10 };
During init:
renderer.init(gl, renderModes);
renderer.enable(gl, false);
I change color with:
renderState.setColorStatic(r, g, b, a);
I set the ortho with:
renderer.reshapeOrtho(width, height, near, far);
And I print the text with:
int fontSize = 20;
int dpiH = 96;
float pixelSize = font.getPixelSize(fontSize, dpiH);
PMVMatrix pmv = renderer.getMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glPushMatrix();
pmv.glTranslatef(x, y, z);
renderer.enable(gl, true);
textRegionUtil.drawString3D(gl, renderer, font, pixelSize, text, null, sampleCount);
renderer.enable(gl, false);
pmv.glPopMatrix();
My text is rendered on the screen but is very bad, like not antialiased. As the same happens with other fonts.
Any suggestion to make the font "beautiful"?
Thanks in advance
|