1
\$\begingroup\$

I am new to OpenGL ES 1 in android. My 3D Model border getting Jagged. Please help me to look like a smooth border instead of jagged.

Screenshot : https://i.sstatic.net/1Gq83.png

private class Renderer implements GLSurfaceView.Renderer {
    public Renderer() {
        setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        getHolder().setFormat(PixelFormat.TRANSLUCENT);
        setZOrderOnTop(true);
    }

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        gl.glClearColor(0.0f,0.0f,0.0f, 0.0f);
        gl.glDisable(GL10.GL_DITHER);
        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_SRC_ALPHA_SATURATE, GL10.GL_ONE);
        gl.glDepthFunc(GL10.GL_LEQUAL);
        gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glShadeModel(GL10.GL_SMOOTH);
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        mViewWidth = (float)w;
        mViewHeight = (float)h;
        gl.glViewport(0,0,w,h);

        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        GLU.gluPerspective(gl, 45, mViewWidth/mViewHeight, 0.1f, 100f);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glPushMatrix();

        gl.glDisable(GL10.GL_DITHER); 

        GLU.gluLookAt(gl, 0, 0, 10, 0, 0, 0, 0, 1, 0);

        //draw_model
        gl.glPushMatrix();

        if(mOrigin != null && mRotate != null) {
            gl.glTranslatef(mOrigin.x, mOrigin.y, mOrigin.z);
            gl.glRotatef(mRotate.x, 1f, 0f, 0f);
            gl.glRotatef(mRotate.y, 0f, 1f, 0f);
            gl.glRotatef(mRotate.z, 0f, 0f, 1f);
        }

        if(mModel != null) {
            mModel.draw(gl);
            if(!RendererView.textureFileName.equals(""))
                mModel.bindTextures(mContext, gl);
        }

        gl.glPopMatrix();
        gl.glPopMatrix();

        if(isPictureTake) {

            w = getWidth();
            h = getHeight();
            b = new int[w*(y+h)];
            bt = new int[w*h];

            IntBuffer ib = IntBuffer.wrap(b);
            ib.position(0);
            gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ib);
            createBitmapFromGLSurface(context);
            isPictureTake = false;
        }
    }
}

Thanks in advance.

\$\endgroup\$
2
  • \$\begingroup\$ why r u using ES 1? ES 1 doesn't support programmable pipe line, is there any specific reason? \$\endgroup\$ Commented Feb 20, 2014 at 6:34
  • \$\begingroup\$ @Tofu_Craving_Redish_BlueDragon No reason, When I start to make my app then I mainly found ES 1 examples, you can recommend me to which version should I try \$\endgroup\$
    – user32900
    Commented Feb 20, 2014 at 6:37

1 Answer 1

2
\$\begingroup\$

if you were using ES 2.0 you can do something like GL_LINE_SMOOTH then the line will get smoothed out themselves tutorials on that here.

  • Solution 00 : If you still want o use ES 1.0 still, I recommend what Lasse said in chat; draw anti-aliased texture then render it as your line.

  • Solution 01 : Another easier way to do so will be preparing "anti-aliased" texture image with alpha value then draw it where you want to have "smooth line" (Prepare blurred square picture. Then resize/draw it where you want to have "smooth line").

    enter image description here (example of "smooth" texture that can be used for Solution 01)

But really both of them are same in nature; prerender texture for the effect you want, then draw it when you need it.

\$\endgroup\$
0

You must log in to answer this question.