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

     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 }
  • 相关阅读:
    sqoop常用命令三 ---- import导入 与export 覆盖更新,常见问题总结
    Sqoop 数据导出:全量、增量、更新
    idea 安装热部署插件
    Python学习之turtle绘图篇
    使用python自动画一只小猪佩奇(源码)
    Python turtle安装和使用教程
    PYCHARM三方库安装方法
    Impala编译部署-3
    SSLv3 SSLContext not available Tomcat
    SSLv3 SSLContext not available Tomcat
  • 原文地址:https://www.cnblogs.com/newlist/p/3151164.html
Copyright © 2011-2022 走看看