• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ paintGL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: while

void GLWidget::setDATModelVector(QVector< QVector<float> > data_vector, float max, float maxy){
	QVector< QVector<float> > calculated_points = QVector< QVector<float> >();
	int i = 0;
	while(i < data_vector.size()){
		calculated_points.push_back(QVector<float>());
		i++;
	}

	float value_of_a_point = 2.0/data_vector[0].size();

	float step_x = (max*value_of_a_point);

	i = 0;
	while(i < data_vector.size()){
		int j = 0;
		float current_x = -1;
		while(j < data_vector[i].size()){
			int index = nearestIndex(current_x, data_vector[i]);

			calculated_points[i].push_back( ((data_vector[i][index]/max)*2) - 1);
			calculated_points[i+1].push_back( (data_vector[i + 1][index]/max) - 1);

			current_x = current_x + step_x;
			j++;
		}
		i = i + 2;
	}
	points = calculated_points;
	max_y = maxy;
	max_x = max;
	shouldpaint = true;
	isDAT = true;
	paintGL();
	updateGL();
}
开发者ID:mskubenich,项目名称:NanoAnalyzer,代码行数:35,代码来源:GLWidget.cpp


示例17: animate

// Redraw function
void OGLViewer::paintEvent(QPaintEvent *e)
{
	if (isSim)
	{
		// Update status
		animate();

		// Update fps at window title
		process_fps = 1000.0 / process_time.elapsed();

		// Time delay
		while (1000.0 * timestep > process_time.elapsed())
		{
		}
	}
	else
	{
		process_fps = 1000.0 / process_time.elapsed();
	}
	process_time.start();
	// Draw current frame
	paintGL();
	/*unsigned char *tex_pixels = new unsigned char[width() * height() * 3];
	//glReadPixels(0, 0, width(), height(), GL_RGB, GL_UNSIGNED_BYTE, tex_pixels);

	//ImageData img(width(), height(), tex_pixels);
	//img.writeFile("img_" + std::to_string(tcount) + ".png");*/
}
开发者ID:ShenyaoKe,项目名称:PhysicallyBasedModeling,代码行数:29,代码来源:OGLViewer.cpp


示例18: paintGL

void GLTDisp::paintEvent(QPaintEvent *)
{
//makeCurrent();

  if (!glLock)
    paintGL();

  QPainter painter(this);
  painter.setRenderHint(QPainter::Antialiasing);

  painter.setRenderHint(QPainter::TextAntialiasing);

  if (glLock)
    painter.drawPixmap(0, 0, glPixmap);
  else {
    swEvent->setEvent(currEvent);
    swEvent->drawWindow(&painter, vpWidth, vpHeight);
  }

  if (subWin)
    subWin->drawWindow(&painter, vpWidth, vpHeight, 
		       (lsNstep > 0) ? (float)aStep/lsNstep : 1);

  if (darkOpt)
    painter.fillRect(0, 0, vpWidth, vpHeight, QColor(0, 0, 0, 150));

  resetButton(&painter);

  painter.end();
}
开发者ID:krafczyk,项目名称:AMS,代码行数:30,代码来源:gltdisp.cpp


示例19: glGetString

void View::initializeGL()
{
    cout << "Using OpenGL Version " << glGetString(GL_VERSION) << endl << endl;

    glEnable(GL_TEXTURE_2D);
    createShaderPrograms();

    // All OpenGL initialization *MUST* be done during or after this
    // method. Before this method is called, there is no active OpenGL
    // context and all OpenGL calls have no effect.

    // Start a timer that will try to get 60 frames per second (the actual
    // frame rate depends on the operating system and other running programs)
    //time.start();
    //timer.start(1000 / 60);

    // Start the drawing timer
    m_timer.start(1000.0f / MAX_FPS);

    // Center the mouse, which is explained more in mouseMoveEvent() below.
    // This needs to be done here because the mouse may be initially outside
    // the fullscreen window and will not automatically receive mouse move
    // events. This occurs if there are two monitors and the mouse is on the
    // secondary monitor.
    QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));

    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glEnable(GL_COLOR_MATERIAL);
    glShadeModel(GL_SMOOTH);

    // Enable depth testing, so that objects are occluded based on depth instead of drawing order
    glEnable(GL_DEPTH_TEST);
    // Setup blending
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    // Setup the cube map
    setupCubeMap();

    // Enable alpha
    glEnable(GL_ALPHA_TEST);

    setupScene();

    // Load the snow texture
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowflake_design.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/second-snowflake.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowball-texture.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowflake-icon.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/actual-snowflake.png" ) );
    m_snowEmitter.setTextures(&m_snowflakeTextures);

    m_snowTextureId = ResourceLoader::loadTexture( ":/textures/textures/plain-surface.jpg" );

    updateCamera();

    setupLights();
    glFrontFace(GL_CCW);
    paintGL();
}
开发者ID:jzweig,项目名称:snow-gl,代码行数:60,代码来源:view.cpp


示例20: assert

	/**
	* @brief resize the GL window
	* @author Kito Berg-Taylor
	*/
	void OgreWidget::resizeGL(int width, int height)
	{
		assert(_mOgreWindow);
		_mOgreWindow->reposition(this->pos().x(), this->pos().y());    
		_mOgreWindow->resize(width, height);
		paintGL();
	}
开发者ID:JasonForrest,项目名称:Modules,代码行数:11,代码来源:qogrewidget.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ paint_black函数代码示例发布时间:2022-05-30
下一篇:
C++ paintButton函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap