| 124 | void RenderView::pollEvents() {} |
| 125 | |
| 126 | void RenderView::updateDesignResolutionSize() |
| 127 | { |
| 128 | if (_screenSize.width > 0 && _screenSize.height > 0 && _designResolutionSize.width > 0 && |
| 129 | _designResolutionSize.height > 0) |
| 130 | { |
| 131 | _scaleX = (float)_screenSize.width / _designResolutionSize.width; |
| 132 | _scaleY = (float)_screenSize.height / _designResolutionSize.height; |
| 133 | |
| 134 | if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) |
| 135 | { |
| 136 | _scaleX = _scaleY = MAX(_scaleX, _scaleY); |
| 137 | } |
| 138 | |
| 139 | else if (_resolutionPolicy == ResolutionPolicy::SHOW_ALL) |
| 140 | { |
| 141 | _scaleX = _scaleY = MIN(_scaleX, _scaleY); |
| 142 | } |
| 143 | |
| 144 | else if (_resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) |
| 145 | { |
| 146 | _scaleX = _scaleY; |
| 147 | _designResolutionSize.width = ceilf(_screenSize.width / _scaleX); |
| 148 | } |
| 149 | |
| 150 | else if (_resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) |
| 151 | { |
| 152 | _scaleY = _scaleX; |
| 153 | _designResolutionSize.height = ceilf(_screenSize.height / _scaleY); |
| 154 | } |
| 155 | |
| 156 | // calculate the rect of viewport |
| 157 | float viewPortW = _designResolutionSize.width * _scaleX; |
| 158 | float viewPortH = _designResolutionSize.height * _scaleY; |
| 159 | |
| 160 | _viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, |
| 161 | viewPortH); |
| 162 | |
| 163 | // reset director's member variables to fit visible rect |
| 164 | auto director = Director::getInstance(); |
| 165 | director->_winSizeInPoints = getDesignResolutionSize(); |
| 166 | director->_isStatusLabelUpdated = true; |
| 167 | director->setProjection(director->getProjection()); |
| 168 | |
| 169 | // Github issue #16139 |
| 170 | // A default viewport is needed in order to display the FPS, |
| 171 | // since the FPS are rendered in the Director, and there is no viewport there. |
| 172 | // Everything, including the FPS should renderer in the Scene. |
| 173 | // TODO: minggo |
| 174 | // glViewport(0, 0, _screenSize.width, _screenSize.height); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | void RenderView::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy) |
| 179 | { |
nothing calls this directly
no test coverage detected