Esempio n. 1
0
void MyExaminerViewer::actualRedraw()
{
    // Must set up the OpenGL viewport manually, as upon resize
    // operations, Coin won't set it up until the SoGLRenderAction is
    // applied again. And since we need to do glClear() before applying
    // the action..
    const SbViewportRegion vp = this->getViewportRegion();
    SbVec2s origin = vp.getViewportOriginPixels();
    SbVec2s size = vp.getViewportSizePixels();
    glViewport(origin[0], origin[1], size[0], size[1]);

    const SbColor col = this->getBackgroundColor();
    glClearColor(col[0], col[1], col[2], 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Render our scenegraph with the image.
    SoGLRenderAction * glra = this->getGLRenderAction();
    glra->apply(this->bckgroundroot);


    // Render normal scenegraph.
    SoQtExaminerViewer::actualRedraw();


    // Increase arrow angle with 1/1000 every frame.
//    arrowrotation->angle = arrowrotation->angle.getValue() + (0.001 / M_PI * 180);
    // Render overlay front scenegraph.
    glClear(GL_DEPTH_BUFFER_BIT);
    glra->apply(this->foregroundroot);
}
void SoXipGetCameraProperties::GLRender(SoGLRenderAction* action)
{
    /*
	SbMatrix mMV = SoModelMatrixElement::get(action->getState()) * SoViewingMatrixElement::get(action->getState());
    SbMatrix mv = mMV.transpose();
    mv = mv.inverse();
    SbVec3f cc(0.0,0.0,0.0);
    SbVec3f wc;
    mv.multMatrixVec(cc, wc);
    */
    SbViewVolume vv = SoViewVolumeElement::get( action->getState() );

    mCamPos = vv.getSightPoint(0.0);
    if (mCamPos != camPos.getValue())
        camPos.setValue( mCamPos );

    mCamDir = vv.getSightPoint(1.0) - vv.getSightPoint(0.0);
    if (mCamDir != camDir.getValue() )
        camDir.setValue( mCamDir );

    SbViewportRegion vpr = SoViewportRegionElement::get( action->getState() );
    SbVec2s orig = vpr.getViewportOriginPixels();
    SbVec2s wh = vpr.getViewportSizePixels();
    SbVec4f vp = SbVec4f( (float)orig[0], (float)orig[1], (float)wh[0], (float)wh[1] );

    mViewport = vp;
    if (mViewport != viewport.getValue())
        viewport.setValue( mViewport );
}
void SoViewportRegion::setViewportRegion(const SbViewportRegion vp)
{
	SbVec2s winSize;
	
	viewport.setViewport(vp.getViewportOrigin(), vp.getViewportSize());
	viewport.setWindowSize (vp.getWindowSize());
	viewport.setViewportPixels(vp.getViewportOriginPixels(), 
		vp.getViewportSizePixels());
}
Esempio n. 4
0
/*!
  Update our SoGLRenderAction's viewport settings.

  This will change \e both the information about window dimensions and
  the actual viewport size and origin.

  \sa setWindowSize()
*/
void
SoSceneManager::setViewportRegion(const SbViewportRegion & newregion)
{
#if COIN_DEBUG && 0 // debug
  const SbVec2s & ws = newregion.getWindowSize();
  const SbVec2s & vpop = newregion.getViewportOriginPixels();
  const SbVec2s & vpsp = newregion.getViewportSizePixels();
  SoDebugError::postInfo("SoSceneManager::setViewportRegion",
                         "windowsize=(%d, %d) "
                         "viewportorigin=(%d, %d) "
                         "viewportsize=(%d, %d) ",
                         ws[0], ws[1],
                         vpop[0], vpop[1],
                         vpsp[0], vpsp[1]);
#endif // debug

  PRIVATE(this)->rendermanager->setViewportRegion(newregion);
  PRIVATE(this)->eventmanager->setViewportRegion(newregion);
}