Possible Duplicate:
How to get rid of Jagged edges in Android OpenGL ES?
I want to do Antialiasing in my appliction.But it doesn't work no matter what I did. My code is
public void onSurfaceCreated(GL10 gl, EGLConfig config){
g10 = gl;
gl.glClearColor(0f, 0, 0.0f, 1.0f);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
GL10.GL_REPEAT);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
GL10.GL_REPEAT);
gl.glSampleCoverage(1.f, true);
gl.glEnable(GL10.GL_DITHER);
gl.glEnable(GL10.GL_MULTISAMPLE);
gl.glEnable(GL10.GL_POINT_SMOOTH);
gl.glEnable(GL10.GL_LINE_SMOOTH);
gl.glEnable(GL10.GL_SAMPLE_COVERAGE);
gl.glPointSize(8);
gl.glLineWidth(5);
gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST); // Make round points, not square points
gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST); // Antialias the lines
}
public void draw(GL10 gl){
gl.glClearColor(0f, 0, 0.0f, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnable(GL10.GL_BLEND);
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture[0]);
gl.glFrontFace(GL10.GL_CCW);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, m_TexBuffer[i]);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_VertexBuffer[i]);
gl.glDrawElements(GL10.GL_TRIANGLE_FAN, vertexCount, GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
}
It didn't do any work.Please tell me why. Thank you.
From OpenGL Wiki. Multisampling is a process for reducing aliasing at the edges of rasterized primitives.
You need to enable polygon antialiasing by passing GL_POLYGON_SMOOTH to glEnable(). This causes pixels on the edges of the polygon to be assigned fractional alpha values based on their coverage, as though they were lines being antialiased. Also, if you desire, you can supply a value for GL_POLYGON_SMOOTH_HINT.
Multisampling, also known as multi-sample antialiasing, is a graphics technique used to reduce the appearance of aliased edges. It works by drawing more pixels than are actually in the final render target, then averaging values to maintain the appearance of a "partial" edge in certain pixels.
A Multisample Texture is a Texture that can have multiple samples per pixel, thereby allowing it to be used in multisampled rendering. As they are textures, their multiple samples can also be fetched from shaders.
If you want to do FSAA, you need to create an EGL context with multisampling enabled. Write an EGLConfigChooser that returns a multisampling config (specify 1 for EGL_SAMPLE_BUFFERS), and pass it to setEGLConfigChooser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With