[osg-users] off screen rendering with OSG

2019-05-13 Thread Sorin Rob
Hello,
In my project, I need to render an OSG frame without any window appearing
on the screen. So called "off screen".
In order to do that, I found the following code taken osgprerenderer.cpp
that I intend to inspire from if I can make it work correctly:

AsyncRTTViewer class:

/* -*-c++-*- Taken from osgprerenderer.cpp
 *
 * This application is open source and may be redistributed and/or
modified
 * freely and without restriction, both in commericial and non commericial
applications,
 * as long as this copyright notice is maintained.
 *
 * This application is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 g++ -losgShadow -losgText -losgUtil -losgViewer -losgGA -lOpenThreads
-losg -lGL -lGLU -lglut async_test.cpp

*/
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 


#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 


class AsyncRTTViewer : public osgViewer::Viewer {
public:

  AsyncRTTViewer(){
asyncRTTViewerConstructorInit();
  }

  AsyncRTTViewer(osg::ArgumentParser& arguments)
: osgViewer::Viewer(arguments) {
asyncRTTViewerConstructorInit();
  }

  AsyncRTTViewer(const osgViewer::Viewer& viewer,
 const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
: osgViewer::Viewer(viewer,copyop) {
asyncRTTViewerConstructorInit();
  }

  virtual ~AsyncRTTViewer() {}

  /// adds a render to texture camera
  void addOffScreenRTTNode(osg::Node* node){
offScreenNodes->addChild(node);
  }

  /// removes a render to texture camera
  void removeOffScreenRTTNode(osg::Node* node){
offScreenNodes->removeChild(node);
  }

  /** call this function to render the off screen scene.
  If no off screen nodes (RTT) are supplied than nothing is done
  */
  virtual void renderOffScreen( ) {
if (_done || offScreenNodes->getNumChildren() == 0) return;

osg::Node* origNode = _camera->getChild(0);
_camera->setChild(0,offScreenNodes);
//printf("before offscreen\n");
offScreenRenderingTraversals();
//printf("after offscreen\n");
_camera->setChild(0,origNode);
  }

protected:


  virtual void offScreenRenderingTraversals() {

/*** This is copied from ViewerBase::renderingTraversals() and
 statistics and swapbuffer and so on are removed.
*/

if (_done) return;

offScreenNodes->getBound();

Contexts contexts;
getContexts(contexts);

Cameras cameras;
getCameras(cameras);

Contexts::iterator itr;

bool doneMakeCurrentInThisThread = false;

if (_endDynamicDrawBlock.valid())
  {
_endDynamicDrawBlock->reset();
  }

// dispatch the rendering threads
if (_startRenderingBarrier.valid()) _startRenderingBarrier->block();

// reset any double buffer graphics objects
for(Cameras::iterator camItr = cameras.begin();
camItr != cameras.end();
++camItr)
  {
osg::Camera* camera = *camItr;
osgViewer::Renderer* renderer =
dynamic_cast(camera->getRenderer());
if (renderer)
  {
if (!renderer->getGraphicsThreadDoesCull() &&
!(camera->getCameraThread()))
  {
renderer->cull();
  }
  }

  }

for(itr = contexts.begin();
itr != contexts.end();
++itr)
  {
if (_done) return;
if (!((*itr)->getGraphicsThread()) && (*itr)->valid())
  {
doneMakeCurrentInThisThread = true;
makeCurrent(*itr);
(*itr)->runOperations();
  }
  }

/*for (itr = contexts.begin();
itr != contexts.end() && !_done;
++itr)
{
if (!((*itr)->getGraphicsThread()) && (*itr)->valid())
{
doneMakeCurrentInThisThread = true;
makeCurrent(*itr);
(*itr)->swapBuffers();
}
}*/

// osg::notify(osg::NOTICE)<<"Joing _endRenderingDispatchBarrier block
"<<_endRenderingDispatchBarrier.get()tick();
_endDynamicDrawBlock->block();
// osg::notify(osg::NOTICE)<<"Time waiting
"tick())< offScreenNodes;
};




struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback
{
  MyCameraPostDrawCallback(osg::Image* image):
_image(image)
  {
  }

  virtual void operator () (osg::RenderInfo& renderInfo) const
  {
if (_image && _image->getPixelFormat()==GL_RGBA &&
_image->getDataType()==GL_UNSIGNED_BYTE)
  {
printf("hello from image processing\n");
// we'll pick out the center 1/2 of the whole image,
int column_start = _image->s()/4;
int column_end = 3*column_start;

int row_start = _image->t()/4;
int 

[osg-users] off-screen rendering issue using slaved camera

2011-11-07 Thread bart gallet
Howdy all 

I am using OSG for generating synthetic environments for AI agents.

I have two views: one that chases the simulated autonomous vehicle and one that 
is taken from the simulated vehicle's payload (pan-tilt-zoom camera). 

I have a third context, a pbuffer, that is assigned to a camera slaved with the 
pan-tilt-zoom camera, so that I can easily ship the pixelbuffer to CPU space 
where the AI engine processes the images (according to what the pan-tilt-zoom 
camera sees). 

It all works fine when I render terrain that was loaded from a terrapage 
database (.txp). 

However the troubles starts when I replace my terrain with a scene generated by 
osgOcean: I do see the ocean scene in the chase view camera viewer window and 
also in the pan-tilt-zoom camera viewer window, but when I inspect the images 
from the slaved off-screen camera that are saved to a jpg on disk, I don't see 
anything - just the default blue-purple background.

Anybody have an idea what might be causing this behaviour?

My system: Intel Core i7 CPU Q820, 8GB, Windows 7 (service pack1) NVIDIA Quadro 
FX 1800M and using latest release version of OSG. 


Cheers,
bart

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=43729#43729





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


Re: [osg-users] Off-screen rendering

2008-04-29 Thread Rafa Gaitan
Hi xbee,

The double buffer is disabled in our code, but is working ok, in offscreen,

If offscreen is not working for you, you should create a 1px width, height
viewer, and set the viewport to the correct with, height of your application
and also activate double buffer. I've never test this, but in theory
should work. :)

We are working on an application that should run on many graphics cards and
systems, so is possible that in the future we have to adopt some similar
solution.

Rafa.



On Mon, Apr 28, 2008 at 9:03 PM, xbee [EMAIL PROTECTED] wrote:

 nicolas peña a écrit :
  This sound like if your hardware / driver does not support pbuffers,
  I have used similar  code in the past and it worked for me.
 
  Cheers,
 
Nicolas
 
  2008/4/28 Tessier, Philip [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED]:
 

 I've the same issue if I don't create a viewer before. With this
 technique, we need a viewer and we have a blink on the screen when the
 snapshot is done :(

 Cheers


 --
 _
   /_/_  .'''.
=O(X ...' `.
   \_\  `..'''
  `..'
 Power corrupts. PowerPoint corrupts absolutely.
 My personnal (french) Websites: http://www.xbee.net
 and http://www.french-comics-zone.fr.st

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




-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Off-screen rendering

2008-04-29 Thread Adrian Egli OpenSceneGraph (3D)
May we could prepare a new example: osgOffscreenRender for server side
rendering (framebuffer) streaming ,...

2008/4/29 Rafa Gaitan [EMAIL PROTECTED]:

 Hi xbee,

 The double buffer is disabled in our code, but is working ok, in
 offscreen,

 If offscreen is not working for you, you should create a 1px width, height
 viewer, and set the viewport to the correct with, height of your application
 and also activate double buffer. I've never test this, but in theory
 should work. :)

 We are working on an application that should run on many graphics cards
 and systems, so is possible that in the future we have to adopt some similar
 solution.

 Rafa.




 On Mon, Apr 28, 2008 at 9:03 PM, xbee [EMAIL PROTECTED] wrote:

  nicolas peña a écrit :
   This sound like if your hardware / driver does not support pbuffers,
   I have used similar  code in the past and it worked for me.
  
   Cheers,
  
 Nicolas
  
   2008/4/28 Tessier, Philip [EMAIL PROTECTED]
   mailto:[EMAIL PROTECTED]:
  
 
  I've the same issue if I don't create a viewer before. With this
  technique, we need a viewer and we have a blink on the screen when the
  snapshot is done :(
 
  Cheers
 
 
  --
  _
/_/_  .'''.
 =O(X ...' `.
\_\  `..'''
   `..'
  Power corrupts. PowerPoint corrupts absolutely.
  My personnal (french) Websites: http://www.xbee.net
  and http://www.french-comics-zone.fr.st
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 



 --
 Rafael Gaitán Linares
 Instituto de Automática e Informática Industrial http://www.ai2.upv.es
 Ciudad Politécnica de la Innovación
 Universidad Politécnica de Valencia

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




-- 

Adrian Egli
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Off-screen rendering

2008-04-28 Thread Tessier, Philip
Hmmm.  I'm using Rafa's code, and am getting the failed to create pbuffer 
message each time.
 
Is there some initialization that must preceed this to get it to work?
 
Thanks,
Phil



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rafa Gaitan
Sent: Sunday, April 27, 2008 4:53 PM
To: [EMAIL PROTECTED]; OpenSceneGraph Users
Subject: Re: [osg-users] Off-screen rendering


Hi Philip and xbee

We have this code and is working for us:

osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x =x;
traits-y = y;
traits-width = width;
traits-height = height;
traits-windowDecoration = false;
traits-doubleBuffer = false;
traits-sharedContext = 0;
traits-pbuffer = true;

osg::GraphicsContext* _gc= 
osg::GraphicsContext::createGraphicsContext(traits.get());

if (!_gc)
{
osg::notify(osg::NOTICE)Failed to create pbuffer, failing back to 
normal graphics window.std::endl;

traits-pbuffer = false;
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
v-getCamera()-setGraphicsContext(_gc);
v-getCamera()-setViewport(new osg::Viewport(x,y,width,height));

v is an osgViewer::Viewer.

Hope this helps.



On Sun, Apr 27, 2008 at 7:49 PM, xbee [EMAIL PROTECTED] wrote:


Tessier, Philip a écrit :

 My attempt to use createGraphicsContext() to create an off-screen
 rendering context is failing.  (It's returning NULL.)

 I'm using Win32.

 What am I missing?

 I have added the following to my code:
 osg::GraphicsContext * GetOffscreenGraphicsContext(
   unsigned a_tex_width,
   unsigned a_tex_height
   )
 {
   osg::ref_ptrosg::GraphicsContext::Traits traits=new
 osg::GraphicsContext::Traits;

   traits-width = a_tex_width;
   traits-height = a_tex_height;
 //traits-doubleBuffer = true;
   traits-pbuffer = true;

   osg::ref_ptrosg::GraphicsContext
 gc=osg::GraphicsContext::createGraphicsContext(traits.get());
   // TODO: Above returning NULL!

   return gc.get();
 }

 with the following to hook it in:
   // Setup camera for off-screen rendering.
   osg::ref_ptrosg::GraphicsContext gc=
 GetOffscreenGraphicsContext( tex_width, tex_height);
   camera-setGraphicsContext(gc.get());

 Thanks,
 Phil



Hi,
Found any solution ? I've the same problem, I have a previous solution
with Producer but I want to port my snapshot application to 2.4 release
and I can't save any image without a viewer. Anyone have a solution ?

Thanks

--
   _
  /_/_  .'''.
   =O(X ...' `.
  \_\  `..'''
 `..'
Power corrupts. PowerPoint corrupts absolutely.
My personnal (french) Websites: http://www.xbee.net
and http://www.french-comics-zone.fr.st


___
osg-users mailing list
osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





-- 
Rafael Gaitán Linares 
Instituto de Automática e Informática Industrial http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Off-screen rendering

2008-04-28 Thread nicolas peña
This sound like if your hardware / driver does not support pbuffers,
I have used similar  code in the past and it worked for me.

Cheers,

  Nicolas

2008/4/28 Tessier, Philip [EMAIL PROTECTED]:

  Hmmm.  I'm using Rafa's code, and am getting the failed to create
 pbuffer message each time.

 Is there some initialization that must preceed this to get it to work?

 Thanks,
 Phil

  --
 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Rafa Gaitan
 *Sent:* Sunday, April 27, 2008 4:53 PM
 *To:* [EMAIL PROTECTED]; OpenSceneGraph Users
 *Subject:* Re: [osg-users] Off-screen rendering

 Hi Philip and xbee

 We have this code and is working for us:

 osg::ref_ptrosg::GraphicsContext::Traits traits = new
 osg::GraphicsContext::Traits;
 traits-x =x;
 traits-y = y;
 traits-width = width;
 traits-height = height;
 traits-windowDecoration = false;
 traits-doubleBuffer = false;
 traits-sharedContext = 0;
 traits-pbuffer = true;

 osg::GraphicsContext* _gc=
 osg::GraphicsContext::createGraphicsContext(traits.get());

 if (!_gc)
 {
 osg::notify(osg::NOTICE)Failed to create pbuffer, failing back
 to normal graphics window.std::endl;

 traits-pbuffer = false;
 _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
 }
 v-getCamera()-setGraphicsContext(_gc);
 v-getCamera()-setViewport(new osg::Viewport(x,y,width,height));

 v is an osgViewer::Viewer.

 Hope this helps.


 On Sun, Apr 27, 2008 at 7:49 PM, xbee [EMAIL PROTECTED] wrote:

  Tessier, Philip a écrit :
My attempt to use createGraphicsContext() to create an off-screen
   rendering context is failing.  (It's returning NULL.)
  
   I'm using Win32.
  
   What am I missing?
  
   I have added the following to my code:
   osg::GraphicsContext * GetOffscreenGraphicsContext(
 unsigned a_tex_width,
 unsigned a_tex_height
 )
   {
 osg::ref_ptrosg::GraphicsContext::Traits traits=new
   osg::GraphicsContext::Traits;
  
 traits-width = a_tex_width;
 traits-height = a_tex_height;
   //traits-doubleBuffer = true;
 traits-pbuffer = true;
  
 osg::ref_ptrosg::GraphicsContext
   gc=osg::GraphicsContext::createGraphicsContext(traits.get());
 // TODO: Above returning NULL!
  
 return gc.get();
   }
  
   with the following to hook it in:
 // Setup camera for off-screen rendering.
 osg::ref_ptrosg::GraphicsContext gc=
   GetOffscreenGraphicsContext( tex_width, tex_height);
 camera-setGraphicsContext(gc.get());
  
   Thanks,
   Phil
  
 
  Hi,
  Found any solution ? I've the same problem, I have a previous solution
  with Producer but I want to port my snapshot application to 2.4 release
  and I can't save any image without a viewer. Anyone have a solution ?
 
  Thanks
 
  --
 _
/_/_  .'''.
 =O(X ...' `.
\_\  `..'''
   `..'
  Power corrupts. PowerPoint corrupts absolutely.
  My personnal (french) Websites: http://www.xbee.net
  and http://www.french-comics-zone.fr.st
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 



 --
 Rafael Gaitán Linares
 Instituto de Automática e Informática Industrial http://www.ai2.upv.es
 Ciudad Politécnica de la Innovación
 Universidad Politécnica de Valencia

 ___
 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


Re: [osg-users] Off-screen rendering

2008-04-28 Thread xbee
nicolas peña a écrit :
 This sound like if your hardware / driver does not support pbuffers,
 I have used similar  code in the past and it worked for me.

 Cheers,

   Nicolas

 2008/4/28 Tessier, Philip [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED]:


I've the same issue if I don't create a viewer before. With this 
technique, we need a viewer and we have a blink on the screen when the 
snapshot is done :(

Cheers


-- 
_
   /_/_  .'''.
=O(X ...' `.
   \_\  `..'''
  `..'
Power corrupts. PowerPoint corrupts absolutely.
My personnal (french) Websites: http://www.xbee.net
and http://www.french-comics-zone.fr.st 

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


Re: [osg-users] Off-screen rendering

2008-04-27 Thread xbee
Tessier, Philip a écrit :
 My attempt to use createGraphicsContext() to create an off-screen
 rendering context is failing.  (It's returning NULL.)

 I'm using Win32.

 What am I missing?

 I have added the following to my code:
 osg::GraphicsContext * GetOffscreenGraphicsContext(
   unsigned a_tex_width,
   unsigned a_tex_height
   )
 {
   osg::ref_ptrosg::GraphicsContext::Traits traits=new
 osg::GraphicsContext::Traits;

   traits-width = a_tex_width;
   traits-height = a_tex_height;
 //traits-doubleBuffer = true;
   traits-pbuffer = true;

   osg::ref_ptrosg::GraphicsContext
 gc=osg::GraphicsContext::createGraphicsContext(traits.get());
   // TODO: Above returning NULL!

   return gc.get();
 }

 with the following to hook it in:
   // Setup camera for off-screen rendering.
   osg::ref_ptrosg::GraphicsContext gc=
 GetOffscreenGraphicsContext( tex_width, tex_height);
   camera-setGraphicsContext(gc.get());

 Thanks,
 Phil
   

Hi,
Found any solution ? I've the same problem, I have a previous solution 
with Producer but I want to port my snapshot application to 2.4 release 
and I can't save any image without a viewer. Anyone have a solution ?

Thanks

-- 
_
   /_/_  .'''.
=O(X ...' `.
   \_\  `..'''
  `..'
Power corrupts. PowerPoint corrupts absolutely.
My personnal (french) Websites: http://www.xbee.net
and http://www.french-comics-zone.fr.st 

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


Re: [osg-users] Off-screen rendering

2008-04-27 Thread Rafa Gaitan
Hi Philip and xbee

We have this code and is working for us:

osg::ref_ptrosg::GraphicsContext::Traits traits = new
osg::GraphicsContext::Traits;
traits-x =x;
traits-y = y;
traits-width = width;
traits-height = height;
traits-windowDecoration = false;
traits-doubleBuffer = false;
traits-sharedContext = 0;
traits-pbuffer = true;

osg::GraphicsContext* _gc=
osg::GraphicsContext::createGraphicsContext(traits.get());

if (!_gc)
{
osg::notify(osg::NOTICE)Failed to create pbuffer, failing back to
normal graphics window.std::endl;

traits-pbuffer = false;
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
v-getCamera()-setGraphicsContext(_gc);
v-getCamera()-setViewport(new osg::Viewport(x,y,width,height));

v is an osgViewer::Viewer.

Hope this helps.


On Sun, Apr 27, 2008 at 7:49 PM, xbee [EMAIL PROTECTED] wrote:

 Tessier, Philip a écrit :
  My attempt to use createGraphicsContext() to create an off-screen
  rendering context is failing.  (It's returning NULL.)
 
  I'm using Win32.
 
  What am I missing?
 
  I have added the following to my code:
  osg::GraphicsContext * GetOffscreenGraphicsContext(
unsigned a_tex_width,
unsigned a_tex_height
)
  {
osg::ref_ptrosg::GraphicsContext::Traits traits=new
  osg::GraphicsContext::Traits;
 
traits-width = a_tex_width;
traits-height = a_tex_height;
  //traits-doubleBuffer = true;
traits-pbuffer = true;
 
osg::ref_ptrosg::GraphicsContext
  gc=osg::GraphicsContext::createGraphicsContext(traits.get());
// TODO: Above returning NULL!
 
return gc.get();
  }
 
  with the following to hook it in:
// Setup camera for off-screen rendering.
osg::ref_ptrosg::GraphicsContext gc=
  GetOffscreenGraphicsContext( tex_width, tex_height);
camera-setGraphicsContext(gc.get());
 
  Thanks,
  Phil
 

 Hi,
 Found any solution ? I've the same problem, I have a previous solution
 with Producer but I want to port my snapshot application to 2.4 release
 and I can't save any image without a viewer. Anyone have a solution ?

 Thanks

 --
_
   /_/_  .'''.
=O(X ...' `.
   \_\  `..'''
  `..'
 Power corrupts. PowerPoint corrupts absolutely.
 My personnal (french) Websites: http://www.xbee.net
 and http://www.french-comics-zone.fr.st

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




-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Off-screen rendering

2008-04-25 Thread Robert Osfield
Hi Phil,

Creating a pbuffer context and then rendering a single frame to this
should work just fine.  You can create the viewer, then just run one
frame and then let it destruct.

Robert.

On Thu, Apr 24, 2008 at 9:48 PM, Tessier, Philip [EMAIL PROTECTED] wrote:



 All,

 I was able to use the osgprerender example to obtain most of what I need -
 the rendering of a scene into an osg::Image.  As that's ALL I want, I need
 help with a tweak to it.  It uses a viewer.run() to do the work.  I've
 replaced this with a viewer.frame().  This produces a flicker on the screen
 as the viewer realizes the frame.  As I'm interested in an off-screen grab,
 this is annoying.

 I'm reasonably sure that I don't want a viewer at all, but I don't know what
 to simplify it to.

 Thanks, in advance,
 Phil

 Philip A. Tessier
 Northrop Grumman IT
 [EMAIL PROTECTED]
 210-867-6775

 ___
  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


Re: [osg-users] Off-screen rendering

2008-04-25 Thread erf
you want to avoid creating a window then and just render the scene given a view 
to a off screen buffer (backbuffer, fbo, pbuffer) and read pixels from it 
without switching to the front buffer. but im new to osg so thats about the 
explanation i could give you :/

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tessier, Philip
Sent: 24. april 2008 23:13
To: OpenSceneGraph Users
Subject: Re: [osg-users] Off-screen rendering

Thank you,
Phil

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeremy
Moles
Sent: Thursday, April 24, 2008 4:08 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Off-screen rendering

On Thu, 2008-04-24 at 15:48 -0500, Tessier, Philip wrote:
 All,

 I was able to use the osgprerender example to obtain most of what I
 need - the rendering of a scene into an osg::Image.  As that's ALL I
 want, I need help with a tweak to it.  It uses a viewer.run() to do
 the work.  I've replaced this with a viewer.frame().  This produces a
 flicker on the screen as the viewer realizes the frame.  As I'm
 interested in an off-screen grab, this is annoying.

 I'm reasonably sure that I don't want a viewer at all, but I don't
 know what to simplify it to.

This is a copy/paste of a response Robert gave to a question like this a
few months ago...

--

Where supported one can use a pbuffer on Win32, X11 and Carbon
implementations in osgViewer. Just create the Traits with the pbuffer
option set to true, then create your GraphicsContext as per the
osgcamera or osgwindows examples.

--

I had recommended looking at how SDL hides the Window, but this is
almost certainly a better solution. :) If you want to get real crazy you
could do something like:

# OSG_WINDOW=0 0 1 1 ./myApp

...but that's an abysmal hack, and still ends up showing a little tiny
block you can't do anything about. :)

 Thanks, in advance,
 Phil

 Philip A. Tessier
 Northrop Grumman IT
 [EMAIL PROTECTED]
 210-867-6775


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
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


Re: [osg-users] Off-screen rendering

2008-04-25 Thread Tessier, Philip
My attempt to use createGraphicsContext() to create an off-screen
rendering context is failing.  (It's returning NULL.)

I'm using Win32.

What am I missing?

I have added the following to my code:
osg::GraphicsContext * GetOffscreenGraphicsContext(
unsigned a_tex_width,
unsigned a_tex_height
)
{
osg::ref_ptrosg::GraphicsContext::Traits traits=new
osg::GraphicsContext::Traits;

traits-width = a_tex_width;
traits-height = a_tex_height;
//  traits-doubleBuffer = true;
traits-pbuffer = true;

osg::ref_ptrosg::GraphicsContext
gc=osg::GraphicsContext::createGraphicsContext(traits.get());
// TODO: Above returning NULL!

return gc.get();
}

with the following to hook it in:
// Setup camera for off-screen rendering.
osg::ref_ptrosg::GraphicsContext gc=
GetOffscreenGraphicsContext( tex_width, tex_height);
camera-setGraphicsContext(gc.get());

Thanks,
Phil


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert
Osfield
Sent: Friday, April 25, 2008 2:43 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Off-screen rendering

Hi Phil,

Creating a pbuffer context and then rendering a single frame to this
should work just fine.  You can create the viewer, then just run one
frame and then let it destruct.

Robert.

On Thu, Apr 24, 2008 at 9:48 PM, Tessier, Philip
[EMAIL PROTECTED] wrote:



 All,

 I was able to use the osgprerender example to obtain most of what I 
 need - the rendering of a scene into an osg::Image.  As that's ALL I 
 want, I need help with a tweak to it.  It uses a viewer.run() to do 
 the work.  I've replaced this with a viewer.frame().  This produces a 
 flicker on the screen as the viewer realizes the frame.  As I'm 
 interested in an off-screen grab, this is annoying.

 I'm reasonably sure that I don't want a viewer at all, but I don't 
 know what to simplify it to.

 Thanks, in advance,
 Phil

 Philip A. Tessier
 Northrop Grumman IT
 [EMAIL PROTECTED]
 210-867-6775

 ___
  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.or
g
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Off-screen rendering

2008-04-24 Thread Tessier, Philip
All,

I was able to use the osgprerender example to obtain most of what I need
- the rendering of a scene into an osg::Image.  As that's ALL I want, I
need help with a tweak to it.  It uses a viewer.run() to do the work.
I've replaced this with a viewer.frame().  This produces a flicker on
the screen as the viewer realizes the frame.  As I'm interested in an
off-screen grab, this is annoying.

I'm reasonably sure that I don't want a viewer at all, but I don't know
what to simplify it to.

Thanks, in advance,
Phil

Philip A. Tessier
Northrop Grumman IT
[EMAIL PROTECTED]
210-867-6775


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


Re: [osg-users] Off-screen rendering

2008-04-24 Thread Jeremy Moles
On Thu, 2008-04-24 at 15:48 -0500, Tessier, Philip wrote:
 All,
 
 I was able to use the osgprerender example to obtain most of what I
 need - the rendering of a scene into an osg::Image.  As that's ALL I
 want, I need help with a tweak to it.  It uses a viewer.run() to do
 the work.  I've replaced this with a viewer.frame().  This produces a
 flicker on the screen as the viewer realizes the frame.  As I'm
 interested in an off-screen grab, this is annoying.
 
 I'm reasonably sure that I don't want a viewer at all, but I don't
 know what to simplify it to.

This is a copy/paste of a response Robert gave to a question like this a
few months ago...

--

Where supported one can use a pbuffer on Win32, X11 and Carbon
implementations in osgViewer. Just create the Traits with the pbuffer
option set to true, then create your GraphicsContext as per the
osgcamera or osgwindows examples.

--

I had recommended looking at how SDL hides the Window, but this is
almost certainly a better solution. :) If you want to get real crazy you
could do something like:

# OSG_WINDOW=0 0 1 1 ./myApp

...but that's an abysmal hack, and still ends up showing a little tiny
block you can't do anything about. :)

 Thanks, in advance, 
 Phil
 
 Philip A. Tessier 
 Northrop Grumman IT 
 [EMAIL PROTECTED] 
 210-867-6775
 
 
 ___
 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