• cocos2dx 简单OpenGL 画图


    void testNode::draw(){
    
        
    
        CCSize s = CCDirector::sharedDirector()->getWinSize();
    
        //线
    
        glLineWidth( 5.0f ); //线宽
    
        ccDrawColor4B(255,0,0,255);//画笔颜色
    
        ccDrawLine( CCPointMake(0, s.height/2), CCPointMake(s.width, s.height/2)
    
                   );//画一条线
    
        ccDrawLine( CCPointMake(s.width/2, 0), CCPointMake(s.width/2, s.height));
    
    //    //方块
    
        ccPointSize(64); //设置方块的大小
    
        ccDrawColor4B(0,0,255,128);
    
        ccDrawPoint(ccp(s.width/2, s.height/2));//位置
    
    //    //ccDrawPoint方法也可以实现自定点的四边形
    
        CCPoint points[] = { ccp(60,60), ccp(70,70), ccp(60,70), ccp(70,60) };
    
    // //也可以群画
    
        ccPointSize(4);//设置大小
    
        ccDrawColor4B(0,255,255,255);
    
        ccDrawPoints( points, 4);//ccDrawPointsvoid
    
    //    ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints )
    
    ////    points 位置 numberOfPoints 个数
    
    //    //画圆形
    
        glLineWidth(0.5f);
    
        ccDrawColor4B(0, 255, 0, 255);
    
        ccDrawCircle(ccp(s.width/2, s.height/2), 100, 0, 20, false);
    
    //    //1,位置2,半径,3角度,4段 5,是否连接上
    
    //    
    
    //    //不规则形状
    
        ccDrawColor4B(255, 255, 0, 255);
    
        glLineWidth(0.5f);
    
        CCPoint vertices[] = { ccp(0,0), ccp(50,50), ccp(100,50), ccp(100,100), ccp(50,100) };
    
        ccDrawPoly( vertices, 5, false);
    
    //    //false 如果改为 ture 会无论画到那都会把开始点和结束点连接上
    
    //    
    
    //    //不规则实体形状
    
    //    glLineWidth(1);
    
    CCPoint filledVertices[] = { ccp(0,120), ccp(50,120), ccp(50,170), ccp(25,200), ccp(0,170) };
    
    ccDrawSolidPoly(filledVertices, 5, ccc4f(0.5f, 0.5f, 1, 1 ) );
    
    //
    
        //画四贝塞尔曲线路径
    
        ccDrawQuadBezier(ccp(100, 100), ccp(200, 200), ccp(300, 100), 30);
    
    //    //开始点控制点结束点分割段数
    
        //画立方贝塞尔曲线路径
    
         ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30, s.height/2+50), ccp(s.width/2-30, s.height/2+50),ccp(200, 200),100);
    
        //不规则平行四边形
    
        CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)};
    
        ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) );
    
        
    
        // restore original values
    
        glLineWidth(1);
    
        ccDrawColor4B(255,255,255,255);
    
        ccPointSize(1);
    }
  • 相关阅读:
    Adding timestamps to terminal prompts
    opensuse nvidia
    小物体检测
    openSUSE 多个GPU设置 深度学习 Caffe PyTorch 等
    openSUSE 高清屏设置
    手把手教你NLTK WordNet使用方法
    [ICCV 2019] Weakly Supervised Object Detection With Segmentation Collaboration
    Instance Segmentation入门总结
    [PAMI 2018] Differential Geometry in Edge Detection: accurate estimation of position, orientation and curvature
    [CVPR2017] Deep Self-Taught Learning for Weakly Supervised Object Localization 论文笔记
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3019937.html
Copyright © 2020-2023  润新知