Re: [osg-users] What is the right way to save a FBO texture to disk?

2012-06-06 Thread John Kaniarz
Thanks, I'll try that. Do I need to unapply the texture state when I'm done?

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





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


Re: [osg-users] What is the right way to save a FBO texture to disk?

2012-06-06 Thread John Kaniarz
It captured a texture, but not the texture I was looking for.


Code:
osg::State * state=renderInfo.getState();
state-applyAttribute(texture);
osg::Image *image=new Image();
image-readImageFromCurrentTexture(renderInfo.getContextID(),false,GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*image,snap.png);



I'm guessing I'm either using the wrong context ID, or that I'm not applying 
the texture in the right way.

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





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


Re: [osg-users] What is the right way to save a FBO texture to disk?

2012-06-06 Thread John Kaniarz
I got it working. The issue is that readImageFromCurrentTexture() doesn't 
support TextureRectangle. I modified my program to use a Texture2D instead and 
it works now.

Adding TextureRectangle support to Image doesn't look like it would be too hard 
except that GL_TEXTURE_BINDING_RECTANGLE isn't a readily available constant. 
(it shows up in gl3.h in the 3.1 section, but I'm sure there's an earlier 
extension)

Thanks for the help,
John

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





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


[osg-users] What is the right way to save a FBO texture to disk?

2012-06-05 Thread John Kaniarz
My program has 4 render to texture cameras that get composited into the frame 
buffer via custom shader.  I want to make a screen capture of one of the 
texture as a response to an event.

Attaching an Image to the camera works, but it copies the data to system memory 
after every frame. Not just when I need it.

I tried calling camera-attach(image); viewer-frame(); 
osgDB::writeImageFile(image); camera-attach(texture); in my event handler, but 
the image saved was blank.

I also tried calling texture-setImage(image), but that image is never updated 
with fresh data.

I also tried calling osg::Image::readPixels() in a Camera::postDrawCallback. 
This doesn't work because RenderStage detaches the FBO before the callback and 
I get a screenshot of the framebuffer instead of the texture. Would calling 
RenderStage::setDisableFboAfterRender(false) fix this? Whats the place to call 
that function from. Will this screw something up when I try to render to the 
actual framebuffer?

Is there another option I haven't thought of? Perhaps manually attaching the 
FBO and calling readPixels?

Thanks,
John

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





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


Re: [osg-users] Rotation Translation problem

2012-06-05 Thread John Kaniarz
Try invert the matrix before attaching it to the camera. A common mistake is to 
think about rotating the camera's view instead of rotating the world into the 
view of the camera.

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





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


Re: [osg-users] Maintaining a reference to an osg node outside of osg

2012-03-16 Thread John Kaniarz
What you're trying to do is the PIMPL design pattern.  I'll leave the details 
to Google :)

You may also want to brush up on the Factory design pattern for generating your 
opaque handles.

In a direct answer to your question, no you can't use a void* to store a 
ref_ptr (without some trickery). You can, however, store a pointer to a 
ref_ptr as a void* . Then when you need to use it, convert it like this to 
avoid having to double dereference it every time you use it.


Code:
ref_ptr Node node = *reinterpret_cast ref_ptr Node *(mysteryPtr);



And don't forget to delete the pointer to the ref_ptr when you're done. if 
you leak the ref_ptr the node will never get collected.

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





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


Re: [osg-users] How do I tell osg the name of my modelview uniform

2012-03-14 Thread John Kaniarz
Thanks! That saved me a lot of cut and paste work. I've been in the c++ mindset 
of avoid the preprocessor for so long that stuff like that doesn't even occur 
to me any more.

However, I'm still interested in an answer to the question. I guess at a more 
fundamental level, the question is, Does OpenScenegraph adapt to your shaders, 
or do you have to adapt your shaders to OpenScenegraph? (and if it's the first 
case, how do you do it.)

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





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


[osg-users] How do I tell osg the name of my modelview uniform

2012-03-12 Thread John Kaniarz
I'm using useModelViewAndProjectionUniforms but I would like to be able to 
use my own variable names.

In a related problem:
I'm using #version 400 in my shaders, and I think that's breaking 
useVertexAtrtibuteAliasing code in osg::State. I get the compiler error 
message declaration of osg_Vertex conflicts with previous declaration. Is 
there any way to tell osg what the name of my vertex variable is? It looks like 
I should be using State::setUpVertexAttribAlias() but it's protected.

I worked around this by binding my vertex data to position 0, and not calling 
Geometry::SetVertexArray()

If someone could point me to a correct example of using tessellation shaders in 
osg I may be able to figure this out myself.

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





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


Re: [osg-users] How do I tell osg the name of my modelview uniform

2012-03-12 Thread John Kaniarz
So I've converted Philip Rideout's tesselation demo to OpenScenegraph. But I'm 
still using the osg_Vertex, osg_ModelViewMatirx, etc. variables. I'm still 
looking for a way to use my own variable names. Is this even possible? Do I 
need to use a node visitor and set the Uniforms manually?

Thanks,
John

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





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


Re: [osg-users] How do I tell osg the name of my modelview uniform

2012-03-12 Thread John Kaniarz
Here's the link to the demo in case you're interested: 
http://prideout.net/blog/?p=48

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





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