• 获取游戏设计的分辨率与真实设备的比例,并根据值来剪切显示区域


     1 /*************************************
     2 *函数名称:visit
     3 *函数功能:获取游戏设计的分辨率与真实设备的比例,并根据值来剪切显示区域
     4 *函数参数:void 
     5 *函数返回值:void 
     6 *笔记:
     7 1.glEnable用于开启opengl相应的功能
     8 2.GL_SCISSOR_TEST根据函数glScissor设置,启用图形剪切
     9 3.glScissor
    10 http://blog.csdn.net/augusdi/article/details/7282214
    11 *************************************/
    12 void CXSroll::visit()
    13 {
    14     glEnable(GL_SCISSOR_TEST);
    15 
    16     CCRect tPrtScr(0, 0, 0, 0);
    17     if (this->getParent())
    18     {
    19         tPrtScr.origin = this->getParent()->convertToWorldSpace(this->getPosition());
    20     }
    21     else
    22     {
    23         tPrtScr.origin = this->getPosition();
    24     }
    25 
    26     tPrtScr.size.width = this->getContentSize().width;
    27     tPrtScr.size.height = this->getContentSize().height;
    28 
    29     //获取游戏设计的分辨率与真实设备的比例
    30     tPrtScr.origin.x /= CCDirector::sharedDirector()->getWinSize().width / CCDirector::sharedDirector()->getOpenGLView()->getFrameSize().width;
    31     tPrtScr.origin.y /= CCDirector::sharedDirector()->getWinSize().height / CCDirector::sharedDirector()->getOpenGLView()->getFrameSize().height;
    32     tPrtScr.size.width /= CCDirector::sharedDirector()->getWinSize().width / CCDirector::sharedDirector()->getOpenGLView()->getFrameSize().width;
    33     tPrtScr.size.height /= CCDirector::sharedDirector()->getWinSize().height / CCDirector::sharedDirector()->getOpenGLView()->getFrameSize().height;
    34 
    35     glScissor( tPrtScr.origin.x, tPrtScr.origin.y, tPrtScr.size.width, tPrtScr.size.height);
    36 
    37     CXWindow::visit();
    38     glDisable(GL_SCISSOR_TEST);
    39 }
  • 相关阅读:
    30-语言入门-30-分数加减法
    29-语言入门-29-两点距离
    bootstrapcss3触屏滑块轮播图
    input输入样式,动画
    HTML5夜空烟花绽放动画效果
    精美留言、评论框,带微博表情
    Sublime Text 3汉化中文版
    直播英国脱欧各国反应?谁将是最大赢家?
    品牌关键字的重要性?是什么呢
    网站收录之网络推广
  • 原文地址:https://www.cnblogs.com/newlist/p/3151164.html
Copyright © 2020-2023  润新知