zoukankan      html  css  js  c++  java
  • 用openGL中的glClipPlanef方法达到从cclayer中抠出矩形图效果

    http://www.devdiv.com/home.php?mod=space&uid=23234&do=blog&id=3310

     

    用openGL中的glClipPlanef方法达到效果

     

    一个相关的链接

    http://paulbourke.net/geometry/planeeq/

     

    写visit方法

    -(void)visit

    {

     

    [selfbeforeDraw];

    [supervisit];

    [selfafterDraw];

     

    }

     

     

    -(void)beforeDraw

    {

     

    float top = 210.0f;;

    float bottom = -130.0f;

     

    float left = -180.0f;

     

    float right = 300.0f;

    //不必修改下面的其他值,上述的常量可以在平面中抠出矩形块,bottom 和 left要为负数

    //至于具体的原理,可以去查看openGL的书籍,上面有详细的介绍,这里,直接用就行

     

     

    GLfloat planeTop[]   = {0.0f, -1.0f, 0.0f,top};

     

    //1.0,y > 100

    GLfloat planeBottom[] = {0.0f, 1.0f, 0.0f,bottom};

     

    //

    GLfloat planeLeft[]   = {1.0f, 0.0f, 0.0f, left};

     

     

    GLfloat planeRight[]  = {-1.0f, 0.0f, 0.0f,right};

     

    glClipPlanef(GL_CLIP_PLANE0, planeTop);

    glClipPlanef(GL_CLIP_PLANE1, planeBottom);

    glClipPlanef(GL_CLIP_PLANE2, planeLeft);

    glClipPlanef(GL_CLIP_PLANE3, planeRight);

    glEnable(GL_CLIP_PLANE0);

    glEnable(GL_CLIP_PLANE1);

    glEnable(GL_CLIP_PLANE2);

    glEnable(GL_CLIP_PLANE3);


     

    }


     

    -(void)afterDraw

    {

    glDisable(GL_CLIP_PLANE0);

    glDisable(GL_CLIP_PLANE1);

    glDisable(GL_CLIP_PLANE2);

    glDisable(GL_CLIP_PLANE3);

    }

  • 相关阅读:
    HDU_1242_Rescue
    HDU_1175_连连看
    HDU_1072_Nightmare
    HDU_2544_最短路
    POJ_2195_Going Home
    POJ_3565_Ants
    KM算法(Kuhn-Munkres)
    POJ_2536_Gopher II
    ODATA 云驱动 http://www.cdata.com/cloud/
    Wijmo 5 与Breeze 的组合,及与METRONIC 的集成
  • 原文地址:https://www.cnblogs.com/ligun123/p/2272094.html
Copyright © 2011-2022 走看看