Search code examples
openglclipping

How to clip only an object ( not all sence ) use glClipPlane?


The question is as the title. If not use glClipPlane, please suggest me a solution for clip a 3D Object ( like Sphere or Torus... ).

Thanks in advance!


Solution

  • In order for glClipPlane to work you have to Enable it using glEnable();

    If you want to clip just one object your code should look like this:

    //draw some stuff
    glEnable(GL_CLIP_PLANE_1);
    glClipPlane(...);
    //draw clipped object
    glDisable(GL_CLIP_PLANE_1);
    //draw some stuff