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


C++ paintGL函数代码示例

本文整理汇总了C++中paintGL函数的典型用法代码示例。如果您正苦于以下问题:C++ paintGL函数的具体用法?C++ paintGL怎么用?C++ paintGL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: earlyPaintGL

/*!
    \internal
*/
void QGLView::paintGL()
{
    d->logEnter("QGLView::paintGL");
    // We may need to regenerate the pick buffer on the next mouse event.
    d->pickBufferMaybeInvalid = true;

    // Paint the scene contents.
    QGLPainter painter;
    QGLAbstractSurface *surface;
    painter.begin();
    if ( (d->options & QGLView::ShowPicking) &&
            d->stereoType == QGLView::RedCyanAnaglyph) {
        // If showing picking, then render normally.  This really
        // only works if we aren't using hardware or double stereo.
        painter.setPicking(true);
        painter.clearPickObjects();
        painter.setEye(QGL::NoEye);
        earlyPaintGL(&painter);
        painter.setCamera(d->camera);
        paintGL(&painter);
        painter.setPicking(false);
    } else if (d->camera->eyeSeparation() == 0.0f &&
               (surface = d->bothEyesSurface()) != 0) {
        // No camera separation, so render the same image into both buffers.
        painter.pushSurface(surface);
        painter.setEye(QGL::NoEye);
        earlyPaintGL(&painter);
        painter.setCamera(d->camera);
        paintGL(&painter);
        painter.popSurface();
    } else {
        // Paint the scene twice, from the perspective of each camera.
        QSize size(this->size());
        painter.setEye(QGL::LeftEye);
        if (d->stereoType != QGLView::Hardware)
            earlyPaintGL(&painter);     // Clear both eyes at the same time.
        painter.pushSurface(d->leftEyeSurface(size));
        if (d->stereoType == QGLView::Hardware)
            earlyPaintGL(&painter);     // Clear the left eye only.
        earlyPaintGL(&painter);
        painter.setCamera(d->camera);
        paintGL(&painter);
        if (d->stereoType == QGLView::RedCyanAnaglyph)
            glClear(GL_DEPTH_BUFFER_BIT);
        painter.setEye(QGL::RightEye);
        painter.setSurface(d->rightEyeSurface(size));
        if (d->stereoType == QGLView::Hardware)
            earlyPaintGL(&painter);     // Clear the right eye only.
        painter.setCamera(d->camera);
        paintGL(&painter);
        painter.popSurface();
    }
    d->logLeave("QGLView::paintGL");
}
开发者ID:Haider-BA,项目名称:walberla,代码行数:57,代码来源:qglview.cpp

示例2: Update

void GLWidget::myTimerSlot()
{
    Update();
    paintGL();
    makeCurrent();
    swapBuffers();
}
开发者ID:Rafal507,项目名称:Postprocesor_MES,代码行数:7,代码来源:glwidget.cpp

示例3: GLInit

void QGLRenderThread::run()
{
    GLFrame->makeCurrent();
    GLInit();
    //LoadShader("../1_1_Waves_Geometry_Shader/Basic.vsh", "../1_1_Waves_Geometry_Shader/Basic.fsh");
    LoadShader("../1_1_Waves_Geometry_Shader/Basic.vsh","../1_1_Waves_Geometry_Shader/Basic.fsh","../1_1_Waves_Geometry_Shader/Basic.gsh");

    while (doRendering)
        {
        if(doResize)
            {
            GLResize(w, h);
            doResize = false;
            }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_CULL_FACE);
        glShadeModel(GL_SMOOTH);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        glEnable(GL_COLOR_MATERIAL);        
        glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
        glLoadIdentity();

        paintGL(); // render actual frame

        FrameCounter++;
        GLFrame->swapBuffers();

        msleep(16); // wait 16ms => about 60 FPS
        }
}
开发者ID:rakesh-malviya,项目名称:GPU-GEMS1,代码行数:33,代码来源:glrenderthread.cpp

示例4: getVector

void Render::mousePressEvent(QMouseEvent *event) {
	if (!mShift) {
		if (event->button() == Qt::RightButton) {
			mOld = mRot;
			Rotating = true;
			mStartPoint = getVector(event->x(), event->y());
		} else if (event->button() == Qt::LeftButton) {
			QMatrix4x4 mat = rotToMatrix();
			QVector3D frustNearPoint = QVector3D(xToViewX(event->x(), mFrustNear), yToViewY(event->y(), mFrustNear), -mFrustNear);
			QVector3D frustFarPoint = QVector3D(xToViewX(event->x(), mFrustFar/mFrustNear), yToViewY(event->y(), mFrustFar/mFrustNear), -mFrustFar);
			QVector3D direction = (frustFarPoint - frustNearPoint);
			QVector3D startPoint = mCamPoint * mat;
			mSelectionDir = (direction * mat);
			qDebug() << mSelectionDir;
			mCamOldPoint = startPoint;
			qDebug() << startPoint;
			mPC.selectNearestPoint(mSelectionDir.normalized(), startPoint);
			for (int i = 0; i < mMesh.Vertices.size()/3; i++) {
				mMesh.SetColorOrTexPos(i, QVector3D(1,1,1));
			}
			for (int i = 0; i < mPC.mSelected.size(); i++) {
				mMesh.SetColorOrTexPos(*mPC.mSelected[i], QVector3D(1,0,0));
			}
			mMesh.uploadVert();
			paintGL();
		}
	} else {
		if (event->button() == Qt::RightButton) {
			mDragging = true;
			updateCurDrag(event);
		}
	}
}
开发者ID:TZer0,项目名称:SkeletalDefiner,代码行数:33,代码来源:render.cpp

示例5: paintGL

void ShowFpsEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
    effects->paintScreen(mask, region, data);
    int fps = 0;
    for (int i = 0;
            i < MAX_FPS;
            ++i)
        if (abs(t.minute() * 60000 + t.second() * 1000 + t.msec() - frames[ i ]) < 1000)
            ++fps; // count all frames in the last second
    if (fps > MAX_TIME)
        fps = MAX_TIME; // keep it the same height
    if (effects->isOpenGLCompositing()) {
        paintGL(fps);
        glFinish(); // make sure all rendering is done
    }
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
    if (effects->compositingType() == XRenderCompositing) {
        paintXrender(fps);
        xcb_flush(xcbConnection());   // make sure all rendering is done
    }
#endif
    if (effects->compositingType() == QPainterCompositing) {
        paintQPainter(fps);
    }
    m_noBenchmark->render(infiniteRegion(), 1.0, alpha);
}
开发者ID:8l,项目名称:kwin,代码行数:26,代码来源:showfps.cpp

示例6: paintGL

/**
* Overrides the virtual paintEvent method of the base class.
* Calls the paintGL() method, then overlays the text using the widget's QPainter
* @param event
*/
void ThreeDWidget::paintEvent(QPaintEvent *event)
{
	paintGL();
	QPainter painter(this);
//	painter.setFont(Settings::m_TextFont);
//	painter.setRenderHint(QPainter::Antialiasing);

	if(m_iView==GLMIAREXVIEW)
	{
		QMiarex* pMiarex = (QMiarex*)s_pMiarex;
		pMiarex->PaintPlaneLegend(painter, rect());
		pMiarex->PaintPlaneOppLegend(painter, rect());
		pMiarex->PaintCpLegendText(painter);
		pMiarex->PaintPanelForceLegendText(painter);

		if(pMiarex->m_bResetTextLegend)
		{
			pMiarex->DrawTextLegend();
		}

		painter.setBackgroundMode(Qt::TransparentMode);
		painter.setOpacity(1);
		painter.drawPixmap(0,0, pMiarex->m_PixText);

	}
	else if(m_iView == GLBODYVIEW)
	{
		GL3dBodyDlg *pDlg = (GL3dBodyDlg*)m_pParent;
		pDlg->PaintBodyLegend(painter);
	}
	else if(m_iView == GLWINGVIEW)
	{
	}
	event->accept();
}
开发者ID:subprotocol,项目名称:xflr5,代码行数:40,代码来源:threedwidget.cpp

示例7: paintGL

void glDispyWidget::redraw() {

    this->makeCurrent();
    //qDebug() << "bnoe";
    paintGL();
    updateGL();
}
开发者ID:sphaero,项目名称:dispy,代码行数:7,代码来源:gldispywidget.cpp

示例8: initializeGL

void drawerWidget::paintEvent(QPaintEvent*)
{
	/*Если буфферы поддерживаются*/
	QPainter painter;
	if(hasbuffers)
	{
		painter.begin(pbuffer);
		pbuffer->makeCurrent();
		initializeGL();
		resizeGL(width(),height());
		paintGL();	
		painter.end();
	
		buffer = pbuffer->toImage().copy(0,512 - height(),width(), height()).convertToFormat(QImage::Format_RGB32);
	
		painter.begin(this);
		painter.drawImage(0,0,buffer);
		painter.end();
	}
	else
	{
		/*Ничего нет!*/
	}
	
}
开发者ID:molefrog,项目名称:astrid,代码行数:25,代码来源:drawerwidget.cpp

示例9: paintGL

/*!
    Returns the registered object that is under the mouse position
    specified by \a point.  This function may need to regenerate
    the contents of the pick buffer by repainting the scene
    with paintGL().

    \sa registerObject()
*/
QObject *QGLView::objectForPoint(const QPoint &point)
{
    // Check the window boundaries in case a mouse move has
    // moved the pointer outside the window.
    if (!rect().contains(point))
        return 0;

    // Do we need to refresh the pick buffer contents?
    QGLPainter painter(this);
    if (d->pickBufferForceUpdate) {
        // Initialize the painter, which will make the window context current.
        painter.setPicking(true);
        painter.clearPickObjects();

        // Create a framebuffer object as big as the window to act
        // as the pick buffer if we are single buffered.  If we are
        // double-buffered, then use the window back buffer.
        bool useBackBuffer = doubleBuffer();
        if (!useBackBuffer) {
            QSize fbosize = size();
            fbosize = QSize(powerOfTwo(fbosize.width()), powerOfTwo(fbosize.height()));
            if (!d->fbo) {
                d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
            } else if (d->fbo->size() != fbosize) {
                delete d->fbo;
                d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
            }
        }

        // Render the pick version of the scene into the framebuffer object.
        if (d->fbo)
            d->fbo->bind();
        painter.clear();
        painter.setEye(QGL::NoEye);
        painter.setCamera(d->camera);
        paintGL(&painter);
        painter.setPicking(false);

        // The pick buffer contents are now valid, unless we are using
        // the back buffer - we cannot rely upon it being valid next time.
        d->pickBufferForceUpdate = useBackBuffer;
        d->pickBufferMaybeInvalid = false;
    } else {
        // Bind the framebuffer object to the window's context.
        makeCurrent();
        if (d->fbo)
            d->fbo->bind();
    }

    // Pick the object under the mouse.
    int objectId = painter.pickObject(point.x(), height() - 1 - point.y());
    QObject *object = d->objects.value(objectId, 0);
    
    // Release the framebuffer object and return.
    painter.end();
    if (d->fbo)
        d->fbo->release();
    doneCurrent();
    return object;
}
开发者ID:slavablind91,项目名称:code,代码行数:68,代码来源:qglview.cpp

示例10: paintGL

void locWmGlDisplay::snapshotToClipboard()
{
    paintGL(); // Redraw the scene in case it needs to be updated.
    QClipboard *cb = QApplication::clipboard(); // get the clipboard
    QImage tempPicture(this->grabFrameBuffer(false)); // grab current image
    cb->setImage(tempPicture); // put current image on the clipboard.
}
开发者ID:josiahw,项目名称:robocup,代码行数:7,代码来源:locWmGlDisplay.cpp

示例11: movingCount

void GLWidget::sceneTimerEvent()
{
	int moveCount= movingCount();

	if(moveCount==1) {
		// 0 1 2 3
		if(movingTo[0]) camera.move(0);
		if(movingTo[1]) camera.move(90);
		if(movingTo[2]) camera.move(180);
		if(movingTo[3]) camera.move(270);
	} else {
		// Diagonals
		if(movingTo[0] && movingTo[1]) camera.move(45);
		if(movingTo[1] && movingTo[2]) camera.move(135);
		if(movingTo[2] && movingTo[3]) camera.move(225);
		if(movingTo[3] && movingTo[0]) camera.move(315);
	}

	// The camera changed position
	if(moveCount) movedWhileGrabbed= true;

	// Only updateGL when needed
	//update();
	paintGL();
}
开发者ID:guitorri,项目名称:QAntenna,代码行数:25,代码来源:glwidget.cpp

示例12: FDEBUG

void OSGQGLManagedWidget::resizeGL(int w, int h)
{   
    FDEBUG (("OSGQGLManagedWidget::resizeGL()\n"));

    _manager->resize(w,h);
    paintGL();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:7,代码来源:OSGQGLManagedWidget_qt.cpp

示例13: setViewport

void GLWidget::setMode(DISPLAY_MODE mode)
{
    m_displayMode = mode;

    setViewport();
    paintGL();
}
开发者ID:fieldOfView,项目名称:uv-mapper,代码行数:7,代码来源:glwidget.cpp

示例14: switch

void Window::keyPressEvent(QKeyEvent* keyEvent)
{
	switch (keyEvent->key()) {
		case Qt::Key_Up:
			Window::interatorY += 0.1f;
			break;
		case Qt::Key_Down:
			Window::interatorY -= 0.1f;
			break;
		case Qt::Key_Left:
			Window::interatorX -= 0.1f;
			break;
		case Qt::Key_Right:
			Window::interatorX += 0.1f;
			break;
		default:
			break;
	}
	/*vec3 origin(interatorX, interatorY, 0.0);
	interator->setOrigin(origin);
	collisionDetector.testCollision();
	if (collisionDetector.hasCollided())
		path.addPoint(collisionDetector.getCollisionPoint());
	else
		mesh->cut(path);*/
	paintGL();
}
开发者ID:Ivesf1m,项目名称:CuttingProject,代码行数:27,代码来源:window.cpp

示例15: glViewport

void CVOpenGLWidget::resizeGL(int width, int height)
{
    glViewport(0, 0, (GLint)width, (GLint)height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glOrtho(0, width, 0, height, 0, 1); // To draw image in the center of the area

    glMatrixMode(GL_MODELVIEW);

    // Scaled Image sizes
    resizedImageHeight_ = width/imageRatio_;
    resizedImageWidth_ = width;

    if( resizedImageHeight_ > height)
    {
        resizedImageWidth_ = height * imageRatio_;
        resizedImageHeight_ = height;
    }

    emit imageSizeChanged( resizedImageWidth_, resizedImageHeight_ );

    positionX_ = (width - resizedImageWidth_)/2;
    positionY_ = (height - resizedImageHeight_)/2;

    sceneChanged_ = true;
    paintGL();
}
开发者ID:amitdash,项目名称:opencv,代码行数:29,代码来源:CVOpenGLWidget.cpp


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