TextRegionUtil and bad result

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

TextRegionUtil and bad result

paolofuse
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
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

elect
Hi,

can we see a screenshot?

You may want to consider to enable multisampling
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

elect
Multisample can help every where except the on "8" and the "d" of "bad"..

God, they are really rendered bad, something seems totally broken on those two.. are they fine in the .ttf?
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
In the .ttf are ok, here you can see it:

https://drive.google.com/file/d/0B682ScIfEmFYS1FmS3hONTZrRWs/view

Same font is rendered well with the old TextRenderer.

For enable multisample you just mean:

gl.glEnable(GL3.GL_MULTISAMPLE);

because if so the result is not getting better.
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

elect
It's not enough, you also need to render to a multisample texture, like here

Anyway, then something is definitely wrong in TextRegionUtil
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
Ok, so I need to render to FBO with multisample texture each time I print a text.... not so comfortable.
I think I'll post a bug about this because I need print text with GL3.
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

elect
paolofuse wrote
Ok, so I need to render to FBO with multisample texture each time I print a text.... not so comfortable.
I think I'll post a bug about this because I need print text with GL3.
Thanks
Yeah, but anyway multisample is not gonna help you with the "8" and the "d", it helps only for aliased borders
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
There is another possibility to print text with GL3 rather than use TextRegionUtil? Someone didn't convert old TextRenderer class?
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

elect
Sorry but I am not expert on that, Gouessej can help you here, he will reply you soon
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
I see that there is a pull request to add OpenGL 3 support to TextRenderer:
https://github.com/sgothel/jogl/pull/47

While I'm waiting for Gouessej reply I download that branch, maybe it will use it.
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

gouessej
Administrator
In reply to this post by paolofuse
There is a pull request containing some code to use the "old" text renderer with GL3.

Oops, you have already found it...
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

paolofuse
Hi Julien,
finally I tried the "old" text renderer with GL3 but I had to fix some bugs:

- the use of VAO was forced, I have made it working with setUseVertexArrays method of TextRenderer
- the setColor method set wrong color, using Green component also for Blue
- calling beginRendering for the first time with a not white (1, 1, 1, 1) color threw an exception, I have created a init() method to call before start rendering

With these changes TextRenderer works perfectly.
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: TextRegionUtil and bad result

gouessej
Administrator
Hi

Please can you mention your fixes in the pull request so that we don't forget your findings? Thank you for the feedback.
Julien Gouesse | Personal blog | Website