Re: [osg-users] I cannot render into an 16 or 32 Bit image

2011-08-12 Thread J.P. Delport

Hi,

search for "hdr" in osgprerender and osgmultiplerendertargets examples.

jp

On 12/08/2011 09:54, "Martin Großer" wrote:

Hello Guys,

I am a little bit dissatisfied. I want to render into an Image. I need the 
pixel data on the cpu memory. That is the reason why I don't use a texture as 
target. Anyway I need a higher precision than 8 bit. So I tried to render into 
an 16 Bit luminance image. Then I got an OpenGL error:

Warning: detected OpenGL error 'invalid enumerant' after RenderBin::draw(,)

I tried other internal formats (i.e. GL_RGBA16F_ARB and GL_RGBA32F_ARB), but I 
got the same message.

Here is partial code from me:

   // init image
   _sumImg = new ::osg::Image;
   _sumImg->allocateImage(1, 1, 1, GL_LUMINANCE16, GL_FLOAT);

   //...

   // init pre render camera
   _preCam = new ::osg::Camera;
   _preCam->setViewport(0,0,1,1);
   _preCam->setProjectionMatrixAsOrtho2D(0,0.1,0,0.1);
   _preCam->setClearColor(::osg::Vec4(0,0,0,1));
   _preCam->setReferenceFrame(::osg::Transform::ABSOLUTE_RF);
   _preCam->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   _preCam->setRenderTargetImplementation(::osg::Camera::FRAME_BUFFER_OBJECT);
   _preCam->attach(::osg::Camera::COLOR_BUFFER0, _sumImg);
   _preCam->setRenderOrder(::osg::Camera::PRE_RENDER);

   // get the pixel color at location (0,0)
   ::osg::Vec4 c = _sumImg->getColor(0,0);


Thanks


Martin


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: [osg-users] I cannot render into an 16 or 32 Bit image

2011-08-12 Thread Sergey Polischuk
Hi, Martin

If you use _sumImg->allocateImage(1, 1, 1, GL_RGBA, GL_FLOAT);
you will get 4 channel * float 32 bit per channel.

If you want GL_LUMINANCE16 you should use GL_UNSIGNED_SHORT, and you may need 
to attach proper rendertarget attachment to camera with same pixel format

Cheers,
Sergey.

12.08.2011, 11:54, ""Martin Großer"" :
> Hello Guys,
>
> I am a little bit dissatisfied. I want to render into an Image. I need the 
> pixel data on the cpu memory. That is the reason why I don't use a texture as 
> target. Anyway I need a higher precision than 8 bit. So I tried to render 
> into an 16 Bit luminance image. Then I got an OpenGL error:
>
> Warning: detected OpenGL error 'invalid enumerant' after RenderBin::draw(,)
>
> I tried other internal formats (i.e. GL_RGBA16F_ARB and GL_RGBA32F_ARB), but 
> I got the same message.
>
> Here is partial code from me:
>
>   // init image
>   _sumImg = new ::osg::Image;
>   _sumImg->allocateImage(1, 1, 1, GL_LUMINANCE16, GL_FLOAT);
>
>   //...
>
>   // init pre render camera
>   _preCam = new ::osg::Camera;
>   _preCam->setViewport(0,0,1,1);
>   _preCam->setProjectionMatrixAsOrtho2D(0,0.1,0,0.1);
>   _preCam->setClearColor(::osg::Vec4(0,0,0,1));
>   _preCam->setReferenceFrame(::osg::Transform::ABSOLUTE_RF);
>   _preCam->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>   _preCam->setRenderTargetImplementation(::osg::Camera::FRAME_BUFFER_OBJECT);
>   _preCam->attach(::osg::Camera::COLOR_BUFFER0, _sumImg);
>   _preCam->setRenderOrder(::osg::Camera::PRE_RENDER);
>
>   // get the pixel color at location (0,0)
>   ::osg::Vec4 c = _sumImg->getColor(0,0);
>
> Thanks
>
> Martin
>
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> ___
> 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


[osg-users] I cannot render into an 16 or 32 Bit image

2011-08-12 Thread Martin Großer
Hello Guys,

I am a little bit dissatisfied. I want to render into an Image. I need the 
pixel data on the cpu memory. That is the reason why I don't use a texture as 
target. Anyway I need a higher precision than 8 bit. So I tried to render into 
an 16 Bit luminance image. Then I got an OpenGL error:

Warning: detected OpenGL error 'invalid enumerant' after RenderBin::draw(,)

I tried other internal formats (i.e. GL_RGBA16F_ARB and GL_RGBA32F_ARB), but I 
got the same message.

Here is partial code from me:

  // init image
  _sumImg = new ::osg::Image;
  _sumImg->allocateImage(1, 1, 1, GL_LUMINANCE16, GL_FLOAT);

  //...

  // init pre render camera
  _preCam = new ::osg::Camera;
  _preCam->setViewport(0,0,1,1); 
  _preCam->setProjectionMatrixAsOrtho2D(0,0.1,0,0.1);
  _preCam->setClearColor(::osg::Vec4(0,0,0,1));
  _preCam->setReferenceFrame(::osg::Transform::ABSOLUTE_RF);
  _preCam->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  _preCam->setRenderTargetImplementation(::osg::Camera::FRAME_BUFFER_OBJECT);
  _preCam->attach(::osg::Camera::COLOR_BUFFER0, _sumImg);
  _preCam->setRenderOrder(::osg::Camera::PRE_RENDER);

  // get the pixel color at location (0,0)
  ::osg::Vec4 c = _sumImg->getColor(0,0);


Thanks


Martin
-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!   
Jetzt informieren: http://www.gmx.net/de/go/freephone
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org