How to get rid of Jagged edges in Android OpenGL ES?

后端 未结 5 551
灰色年华
灰色年华 2020-12-11 06:15

I have the following code:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    gl.glShadeModel(GL10.GL         


        
5条回答
  •  孤街浪徒
    2020-12-11 06:55

    Well the best way is to use Multisampling ( Antialiasing ). Since you use the emulator this is not an option for you. ( Multismapling supported in OpenGL ES 2.0 but the emulator does not support 2.0 ) According to the OpenGL specification, the device can ignore the glHint you set, so don't expect to much from it. The GL_DITHER is a way to 'fake' 24bit color depth from 16bit color depth basically it has nothing to do with the edges.

    Altho there is an old method to 'fake' antialiasing, its a same that I never used so I cant tell you how, but you can find some hints on the web.

    From OpenGL docs

    Blend function (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) is also useful for rendering antialiased points and lines in arbitrary order.

    Polygon antialiasing is optimized using blend function (GL_SRC_ALPHA_SATURATE, GL_ONE) with polygons sorted from nearest to farthest.

提交回复
热议问题