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);

    }

  • 相关阅读:
    Maven初步踩坑
    Sql Server Snapshot和mysql MVCC
    改良程序的11个技巧
    Lucene基础学习笔记
    关于JQuery
    关于JQuery
    JS性能细节学习初步总结
    hibernate.cfg配置mysql方言
    Java 从静态代理到动态代理
    基础复习 关于事务
  • 原文地址:https://www.cnblogs.com/ligun123/p/2272094.html
Copyright © 2011-2022 走看看