Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we get Polygon Antialiasing in OpenGL ES on Android 1.5?

Based on my reading of Ch. 6 in the Red Book, changing the things that need to be changed for ES, I thought the following code should have done it:

gl.glEnable(GL10.GL_POLYGON_SMOOTH);
gl.glBlendFunc(GL10.GL_SRC_ALPHA_SATURATE, GL10.GL_ONE);
gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST); // no visible diff
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
gl.glColor4f(1, 1, 1, 1);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);         // first and count

etc.

But the above fails. There is no visible difference in the output, the aliasing artifacts are just as painfully evident as before the calls to glEnable...glHint were inserted.

Actually, what I just described was when I had GL_LINE_SMOOTH in place of GL_POLYGON_SMOOTH. The latter is not even found! So where is it if not in GL10? Or how could it have been left out of OpenGL ES? How are we supposed to draw filled polygons w/ antialiasing if not with GL_POLYGON_SMOOTH?

like image 917
MattJ Avatar asked Apr 08 '10 20:04

MattJ


1 Answers

Without trying it, what you are doing above does not seem incorrect. However, many phones do not actually support anti-aliasing despite the fact that the API does.

You should be able to achieve full screen anti-aliasing by drawing the screen multiple times while jittering the perpective matrix.

See http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node63.html and this post regarding the same problem on the iPhone

like image 138
Andres Avatar answered Sep 22 '22 12:09

Andres