|
发表于 2013-1-5 12:54:43
|
显示全部楼层
viewPort的height变为0值时,会让投影矩阵的缩放出现问题(除数为0),代码说明了问题:- void GraphicsContext::resizedImplementation(int x, int y, int width, int height)
- {
- std::set<osg::Viewport*> processedViewports;
- if (!_traits) return;
-
- double widthChangeRatio = double(width) / double(_traits->width);
- double heigtChangeRatio = double(height) / double(_traits->height);
- double aspectRatioChange = widthChangeRatio / heigtChangeRatio;
-
复制代码 MFC中正常是因为GraphicsWindowWin32在 resized之前,有这两句判断- int windowWidth = (clientRect.right == 0) ? 1 : clientRect.right ;
- nt windowHeight = (clientRect.bottom == 0) ? 1 : clientRect.bottom;
复制代码 确保了缩放后为有效矩阵。
QT中没有判断视窗的长宽是否为0,如下:- void GLWidget::resizeEvent( QResizeEvent* event )
- {
- const QSize& size = event->size();
- _gw->resized( x(), y(), size.width(), size.height() );
- _gw->getEventQueue()->windowResize( x(), y(), size.width(), size.height() );
- _gw->requestRedraw();
- }
复制代码 之前也遇到了这个问题,在QT中通过widget->setMinimumSize(QSize(10, 10));来防止缩放为0 |
|