Hi Dirk
> > Due to the use of floating point textures, I can't use "grabForeground".
>
> *cringe* You're right, currently the GrabForeground only grabs ubytes. But
> there
> is not really a good reason for that except that the GrabForeground is
> older
> than float buffers. It's a trivial fix:
>
> glReadPixels(port->getPixelLeft(), port->getPixelBottom(),
> w, h, i->getPixelFormat(),
> - GL_UNSIGNED_BYTE, i->getData());
> + i->getDataType(), i->getData());
>
> And it would make your code much simpler. So I consider this a bugfix and
> added
> it to the current codebase. I tested the standard case, can you test the
> float
> case to make sure it's working? All you need to do is create an Image with
> datatype float, and you should get float results.
It is not working! I only get crap! Can you have a quick look over my code,
just in case i screwed up somewhere?
With OSG_UINT8_IMAGEDATA everything works fine.
By the way I'm using the most recent daily build (version 1.8) from today.
grabImage = Image::create();
grabImage->set( Image::OSG_RGBA_PF,
m_imageWidth, m_imageHeight,
1,1,1,0.0,
0, Image::OSG_FLOAT32_IMAGEDATA); // do i need to allocate
memory here?
GrabForegroundPtr grabber = GrabForeground::create();
grabber->setImage(g_grabImage);
grabber->setActive(true);
MFForegroundPtr *foregrounds = g_window->getPort(0)->getMFForegrounds();
foregrounds->push_back (grabber);
// check texture
for (int h=0; h< grabImage->getHeight(); ++h) {
for (int w=0; w< grabImage->getWidth(); ++w) {
float r = ((float*)(grabImage ->getData() +
width*h*Channels*ByteSize))[w*4];
float g = ((float*)(grabImage ->getData() +
width*h*Channels*ByteSize))[w*4+1];
float b = ((float*)(grabImage ->getData() +
width*h*Channels*ByteSize))[w*4+2];
float a = ((float*)(grabImage ->getData() +
width*h*Channels*ByteSize))[w*4+3];
}
}
> > In addition a proposal working entirely on GPU
> > through Nvidia CUDA framework is considered.
>
> Those are the big guns. You can probably do the same thing with normal
> GLSL shaders.
There are no scatter operations for Shaders. Right now there is no easy way to
sum values of a texture.
> > Therefore I need the OpenGL texture ID anyway.
> >
> > I'd appreciate it very much, if someone could point me to the right
> direction, as I'm a bloody beginner in OpenSG
> > so far i tried following:
> >
> > void display (void)
> > {
> > // get the RenderAction from SimpleSceneManager
> > RenderAction *rAct = static_cast<RenderAction*>( mgr->getAction() );
> > // render fbo scene
> > fboViewport->render(rAct);
> > // render main scene
> > mgr->redraw();
> > // readback
> > float* buf= new float ( imageWidth * imageHeight *4 );
> > glBindTexture( GL_TEXTURE_RECTANGLE_ARB,
> fboViewport->getTextures(0)->getGLId() );
>
> The id that's store in the TextureChunk is not th eactual GL id any more
> (unless
> you use an old version).
So, where is the GL id now? :-)
Thanks you so much!
Great forum, great scene graph...
Tobi
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users