One more thing: Rendering to a pbuffer does not automatically give you the
option to access your rendered content as a texture.

The technique to render to texture with pbuffers is called pbuffer-rtt and
implemented in several OSG samples with the "

*--pbuffer-rtt" command line option.*

*This may differ a bit from the camera setup I've outlined above.*



*Christian*

2016-08-18 17:07 GMT+02:00 Christian Buchner <christian.buch...@gmail.com>:

>
> On Windows, create a graphics context with the pbuffer flag set to true
> and windowDecoration set to false.
>
>         osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
> osg::GraphicsContext::Traits;
>         traits->x = 0;
>         traits->y = 0;
>         traits->width = 640;
>         traits->height = 480;
>         traits->red = 8;
>         traits->green = 8;
>         traits->blue = 8;
>         traits->alpha = 8;
>         traits->windowDecoration = false;
>         traits->pbuffer = true;
>         traits->doubleBuffer = false; // or true as needed
>         traits->sharedContext = 0;
>
>         m_pbuffer = osg::GraphicsContext::createGraphicsContext(traits.
> get());
>         if (!m_pbuffer.valid())
>         {
>             osg::notify(osg::NOTICE) << "Pixel buffer has not been created
> successfully. NOTE: update your dependencies folder if you see this error!"
> << std::endl;
>             exit(1);
>         }
>         else
>         {
>             // Create an osgViewer running on top of a pbuffer graphics
> context
>             m_viewer = new osgViewer::Viewer();
>
>             // in my case I use a slave camera with ortho projection
>             // to render whatever is needed
>             m_camera = new osg::Camera;
>             m_camera->setGraphicsContext(m_pbuffer.get());
> m_camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
>             m_camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
>             m_camera->setViewMatrix(osg::Matrix());
>             m_camera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1.0, 0,
> 1.0));
>             m_camera->setViewport(new osg::Viewport(0, 0, 640, 480));
>             m_camera->setDrawBuffer(GL_FRONT);
>             m_camera->setReadBuffer(GL_FRONT);
>             m_viewer->addSlave(m_camera.get(), osg::Matrixd(),
> osg::Matrixd());
>             m_viewer->realize();
>
>
> I do not know if the same would work on Linux, as pbuffers on Linux are an
> optional extension that might not be supported.
>
> I get this to render at arbitrary frame rates, entirely decoupled from the
> screen's VBLANK interval.
>
> Christian
>
>
> 2016-08-18 16:47 GMT+02:00 Chris Thomas <ctho...@soasta.com>:
>
>> Hi,
>>
>> OK, I based my initial integration into my app on osgteapot.cpp. As with
>> all the other examples, it os run via
>>
>> viewer.run();
>>
>> And this creates an output window in OSX (and I am assuming any other OS
>> its run on). And thats the issue I have, I need OSG to run "headless", that
>> is to say, producing no visible window in the OS.
>>
>> If OSG is rendering away, to a non visible buffer, I can then expose this
>> to the user via my UI api (see above). Having this visible viewer, is the
>> issue right now. Is there an option to run viewer with no visible
>> display/window, or is there an alternative to viewer() ?
>>
>> Thank you!
>>
>> Cheers,
>> Chris
>>
>> ------------------
>> Read this topic online here:
>> http://forum.openscenegraph.org/viewtopic.php?p=68420#68420
>>
>>
>>
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to