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 }
  • 相关阅读:
    Python基础(一)
    计算机编程和编程语言
    初始Markdown
    Python模块
    Python递归以及面向过程编程
    Python推导式和匿名函数
    Python学闭包函数和装饰器
    Python函数的特点
    Python文件高级应用和如何使用函数
    Python字符编码和文件处理
  • 原文地址:https://www.cnblogs.com/newlist/p/3151164.html
Copyright © 2011-2022 走看看