Hi again,

Attached is the program we just ran.  It shows the loaded file in a green
camera, with the clear color set to red.

Basically, when you run in quadbuffered stereo the area outside of the
viewport shows whatever cruft was there from the run before in the right
buffer.

For example, if the previous run had a white background, when you run in
stereo the area outside the viewport is pink- red for the left buffer and
white for the right.

Thanks,

John

On Fri, 1 Oct 2010, John Kelso wrote:

Hi,

We have a sort of oddball immersive system where the physical screens are
a bit smaller than the area illuminated by the projectors.  (The projected area
matches the X11 screen size size).  My workaround is to make the viewport
the size of the physical screen, and make the window fullsize.

In our current software, which is an osg/Producer hybrid, the area outside
the viewport is black, done by a setClearColor call.

I'll write a small osgviewer-like program and test it and send my results
and the program back to the list.

Thanks,

John

On Fri, 1 Oct 2010, Robert Osfield wrote:

Hi John,

On Fri, Oct 1, 2010 at 2:21 PM, John Kelso <ke...@nist.gov> wrote:
Is there a way to get osgviewer to create a viewport that is smaller than
its window?

No... you'd need to create the context and setup the camera's viewport
manually to do this.

Your mention of this does make me rather curious, one typically does
stereo fullscreen.

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

#include <osgDB/ReadFile>

#include <osgViewer/Viewer>

#include <osgViewer/ViewerEventHandlers>

#include <osgGA/TrackballManipulator>

#include <iostream>



#include "Nerves.h"



void newWindow(osgViewer::Viewer& viewer, bool stereo, unsigned int sn, char 
*name=NULL)

{

    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
osg::GraphicsContext::Traits;

    //printf("traits->referenceCount() = %d\n",traits->referenceCount()) ;

    traits->screenNum = sn ;

    traits->x = 0 ;

    traits->y = 0 ;

    traits->width = 1000 ;

    traits->height = 1000 ;

    traits->windowDecoration = true;

    traits->doubleBuffer = true;

    traits->sharedContext = 0;

    if (name) traits->windowName = name ;

    traits->quadBufferStereo = stereo ;

    

    osg::ref_ptr<osg::GraphicsContext> gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

    if (gc.valid())

    {

        osg::notify(osg::INFO)<<"  GraphicsWindow has been created 
successfully."<<std::endl;

    }

    else

    {

        osg::notify(osg::NOTICE)<<"  GraphicsWindow has not been created 
successfully."<<std::endl;

    }

    

    // color outside the viewport

    gc->setClearColor(osg::Vec4(1,0,0,1));

    gc->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );



    {

        osg::ref_ptr<osg::Camera> camera = new osg::Camera;

        camera->setGraphicsContext(gc.get());

        camera->setViewport(new osg::Viewport(50, 50, traits->width-100, 
traits->height-100));

        GLenum buffer = GL_BACK ;

        if (stereo) buffer = GL_BACK_LEFT ;

        camera->setDrawBuffer(buffer);

        // color inside the viewport

        camera->setClearColor(osg::Vec4(0,1,0,1)) ;

        viewer.addSlave(camera.get()) ;

    }



    if (stereo)

    {

        osg::ref_ptr<osg::Camera> camera = new osg::Camera;

        camera->setGraphicsContext(gc.get());

        camera->setViewport(new osg::Viewport(50, 50, traits->width-100, 
traits->height-100));

        GLenum buffer = GL_BACK_RIGHT ;

        camera->setDrawBuffer(buffer);

        // color inside the viewport

        camera->setClearColor(osg::Vec4(0,1,0,1)) ;

        viewer.addSlave(camera.get()) ;

    }



}



int main( int argc, char **argv )

{



    osgViewer::Viewer viewer ;

    viewer.addEventHandler(new osgViewer::StatsHandler) ;

    viewer.addEventHandler(new osgViewer::ThreadingHandler) ;



    osg::GraphicsContext::WindowingSystemInterface* wsi = 
osg::GraphicsContext::getWindowingSystemInterface();

    if (!wsi) 

    {

        osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, 
cannot create windows."<<std::endl;

        return 1;

    }



    bool stereo ;

    if (!strcmp("-m",argv[1])) 

    {

        stereo = false ;

        printf("running in mono\n") ;

    }

    else if (!strcmp("-s",argv[1])) 

    {

        stereo = true ;

        printf("running in stereo\n") ;

    }

    else

    {

        printf("Usage: %s -m|-s n ... file\n") ;

        return 1 ;

    }



    for (unsigned int i=2; i<argc-1; i++)

    {

        int sn ;

        sscanf(argv[i],"%d",&sn) ;

        newWindow(viewer,stereo,sn,argv[i]);

    }



    // load the scene.

    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[argc-1]);

    

    if (!loadedModel) 

    {

        std::cout << argv[0] <<": No data loaded." << std::endl;

        return 1;

    }

    

    viewer.setSceneData(loadedModel.get());

    

    viewer.realize();



    if (!viewer.getCameraManipulator() && 
viewer.getCamera()->getAllowEventFocus())

    {

        viewer.setCameraManipulator(new osgGA::TrackballManipulator());

    }

    

    viewer.setReleaseContextAtEndOfFrameHint(false);

            

    viewer.frame() ;



    return viewer.run() ;

}

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to