当前位置: 首页>>代码示例>>C++>>正文


C++ GLWidget::setViewport方法代码示例

本文整理汇总了C++中GLWidget::setViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ GLWidget::setViewport方法的具体用法?C++ GLWidget::setViewport怎么用?C++ GLWidget::setViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GLWidget的用法示例。


在下文中一共展示了GLWidget::setViewport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readFromFrameBuffer_

bool RayCastRenderer::readFromFrameBuffer_( const GLWidget& glWidget,
        const View& view,
        const Frustum &frustum,
        const RenderBrick& renderBrick,
        Vector2i& screenPos )
{
    Viewporti pixViewport;
    glWidget.setViewport( &view, pixViewport );

    Vector2i minPos;
    Vector2i maxPos;

    renderBrick.getScreenCoordinates( frustum, pixViewport, minPos, maxPos );

    const Vector2i texSize = maxPos - minPos;

    const eq::fabric::PixelViewport pixelViewPort( minPos[ 0 ], minPos[ 1 ],
            texSize[ 0 ],  texSize[ 1 ] );
    if( !pixelViewPort.hasArea( ) )
        return false;

    framebufferTempTexturePtr_->copyFromFrameBuffer( GL_RGBA, pixelViewPort );

    screenPos = minPos;

    return true;
}
开发者ID:vr3d,项目名称:Livre,代码行数:27,代码来源:RayCastRenderer.cpp

示例2: QWidget


//.........这里部分代码省略.........
	}
	else
	{
		frameHeight = defHeight / rows;
		frameWidth = (int)((double)frameHeight * (((double)defWidth)/((double)defHeight)));
	}
	
	// Calculate the new canvas size
	int realWidth  = frameWidth  * cols;
	int realHeight = frameHeight * rows;
	glw->setCanvasSize(QSizeF((double)realWidth,(double)realHeight));*/
	
	// If user gives us a window size, use it - otherwise make it the same as the canvas size
	int winWidth  = settings.value("win-width",0).toInt();
	int winHeight = settings.value("win-height",0).toInt();
// 	if(winWidth <= 0 || winHeight <= 0)
// 		resize(realWidth, realHeight);
// 	else
// 		resize(winWidth, winHeight);

	if(winWidth > 0 && winHeight > 0)
		resize(winWidth, winHeight);
	
	// No default window position. 
	// Only set position if both X and Y are given 
	int winX = settings.value("win-x",-1).toInt();
	int winY = settings.value("win-y",-1).toInt();
 	if(winX >= 0 && winY >= 0)
 		move(winX, winY);
	
	//qDebug() << "Layout: "<<cols<<"x"<<rows<<", size:"<<frameWidth<<"x"<<frameHeight;
	
	GLScene *scene = new GLScene();
	GLVideoInputDrawable *drw = 0;
	
	// Finally, get down to actually creating the drawables 
// 	// and setting their positions
// 	for(int i=0; i<numItems; i++)
// 	{
// 		// Load the connection string
// 		QString con = settings.value(tr("input%1").arg(i)).toString();
// 		if(con.indexOf("=") < 0)
// 			con = tr("net=%1").arg(con);
// 			
// 		qDebug() << "Input "<<i<<": "<<con;
// 		
// 		// Create the drawable
// 		drw = new GLVideoInputDrawable();
// 		drw->setVideoConnection(con);
// 		
// 		// Calculate the position in the grid
// 		double frac = (double)i / (double)cols;
// 		int row = (int)frac;
// 		int col = (int)((frac - row) * cols);
// 		
// 		// Translate to "pixels"
// 		int x = col * frameWidth;
// 		int y = row * frameHeight;
// 		
// 		// Set the position
// 		drw->setRect(QRectF(x,y,frameWidth,frameHeight));
// 		
// 		// Finally, add the drawable
// 		scene->addDrawable(drw);
// 	}

	int frameWidth = 1000, frameHeight = 750, x=0, y=0;
	
	drw = new GLVideoInputDrawable();
	drw->setVideoInput("test:1");///dev/video1");
	drw->setRect(QRectF(x,y,frameWidth,frameHeight));
	
	VideoDisplayOptionWidget *widget = new VideoDisplayOptionWidget(drw);
	widget->show();
	
	// Finally, add the drawable
	scene->addDrawable(drw);
	
	drw = new GLVideoInputDrawable();
	drw->setVideoInput("test:1");///dev/video1");
	drw->setRect(QRectF(x + frameWidth,y,frameWidth,frameHeight));
	scene->addDrawable(drw);
	
	// Add the drawables to the GLWidget
	scene->setGLWidget(glw);
	
	glw->setViewport(QRect(0,0,2000, 750));
	
// 	GLSpinnerDrawable *spinner = new GLSpinnerDrawable();;
// 	spinner->setCycleDuration(1);
// 	int spinSize = 28;
// 	QRectF spinnerRect(10,10, spinSize, spinSize);
// 	spinner->setRect(spinnerRect);
// // 	spinner->setFlipVertical(true);
// // 	spinner->setFlipHorizontal(true);
// 	spinner->setZIndex(10.);
// 	spinner->start();	
// 	
// 	glw->addDrawable(spinner);
}
开发者ID:TritonSailor,项目名称:livepro,代码行数:101,代码来源:MainWindow.cpp


注:本文中的GLWidget::setViewport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。