本文介绍了如何在 Android OpenGL ES 中进行多重采样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何摆脱 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.

推荐答案

如果你想做 FSAA,你需要创建一个启用多重采样的 EGL 上下文.编写返回多重采样配置的 EGLConfigChooser(为 EGL_SAMPLE_BUFFERS),并将其传递给 setEGLConfigChooser.

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.

这篇关于如何在 Android OpenGL ES 中进行多重采样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:28