Question

I am trying to clip a 3D model in 3 planes XY,YZ and ZX. When I use GL11.GL_CLIP_PLANE0 it's working but GL11.GL_CLIP_PLANE1 and GL11.GL_CLIP_PLANE2 are not working. The java code I am using is pasted below. It's working fine with Android version 2.2 but not working in versions above 2.2. If anybody knows the reason please post.

enableSectionPlane(GL10 gl)
{
    GL11 gl11 = (GL11) gl;

    if( is_XY_plane)
    {

        float eqn1[] =  { 0.0f, 0.0f, 1.0f,0.0f };
        gl.glEnable( GL11.GL_CLIP_PLANE0);
        gl11.glClipPlanef( GL11.GL_CLIP_PLANE0, eqn1,0 );

    }
    else
    {
        gl.glDisable( GL11.GL_CLIP_PLANE0 );
    }


    if( is_YZ_plane)
    {
        float eqn2[] = { 1.0f, 0.0f, 0.0f,0.0f };           
        gl.glEnable( GL11.GL_CLIP_PLANE1);
        gl11.glClipPlanef( GL11.GL_CLIP_PLANE1, eqn2,0);
    }
    else
    {
        gl.glDisable( GL11.GL_CLIP_PLANE1 );
    }

    if(is_ZX_plane)
    {
        float eqn3[] = { 0.0f, 1.0f, 0.0f,0.0f };
        gl.glEnable( GL11.GL_CLIP_PLANE2 );
        gl11.glClipPlanef( GL11.GL_CLIP_PLANE2, eqn3,0 );
    }
    else
    {
        gl.glDisable( GL11.GL_CLIP_PLANE2 );
    }


}
Was it helpful?

Solution

Use glGet() and GL_MAX_CLIP_PLANES to double-check that your GL implementation supports more than one clip plane. The glGet() docs say it should support at least 6.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top