[osg-users] Accessing StateSets

2011-04-12 Thread Ethan Kerzner
Hi,

I am trying to access the material stored in a stateset. Is this possible? 

My approach is below- the first line returns a null pointer.


Code:
osg::StateAttribute* sa = 
myGeode.getOrCreateStateSet()-getAttribute(osg::StateAttribute::MATERIAL);
osg::Material* mat = dynamic_castosg::Material*(sa);




Thank you!

Cheers,
ethan

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





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


Re: [osg-users] Transform Feedback

2010-06-30 Thread Ethan Kerzner
Hi Paul,

Thanks for your reply. 

I have decided to try using draw callbacks, and the osg encapsulation of shader 
programs. However, I have another question.  

How can we access the OpenGL pointer to an osg::program containing shaders? We 
need this pointer to set up transform feedback. 

I currently try to get the pointer to the per context program as I show below.


Code:

class CameraUpdateCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{ 
std::coutCamera update callback - pre traversenodestd::endl;

//apply the test shaders to the node
node-getOrCreateStateSet()-setAttribute(outputShaders);

//on the first iteration, there is no graphics context, so 
check that there is 

if(viewer-getCamera()-getGraphicsContext()-getState()-getContextID)
{   
GLuint cid  = 
viewer-getCamera()-getGraphicsContext()-getState()-getContextID();
osg::Program::PerContextProgram* pcp = 
feedbackShaders-getPCP(cid);
GLuint shaderID = pcp-getHandle();

//these two lines give errors
 //posLoc = glGetVaryingLocationNV(shaderID, gl_Position);
//glTransformFeedbackVaryingsNV(shaderID, 1, posLoc, 
GL_INTERLEAVED_ATTRIBS_NV);
}



traverse(node,nv);


std::coutCamera update callback - post traversenodestd::endl;


}
};




I would appreciate any help you can provide.


Thanks,
Ethan

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





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


Re: [osg-users] Transform Feedback

2010-06-29 Thread Ethan Kerzner
Hi,

I guess my first question was too vague. Sorry about that. I am still trying to 
use transform feedback on an entire scene inside osg.

I have created a CustomDrawable class with a drawImplementation that can 
perform transform feedback on anything drawn inside it. I am now trying to draw 
the entire scene inside my drawImplementation using a node visitor to traverse 
the graph and locate and draw all of the drawables with transform feedback 
enabled.

I do not understand the parameters of void draw(osg::RenderInfo renderInfo) 
const function. 

Can you please explain what information RenderInfo contains? Is the RenderInfo 
different for each drawable or global for the scene? Is it possible to 
determine the RenderInfo of a drawable?

Thanks,
Ethan

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





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


[osg-users] Transform Feedback

2010-06-21 Thread Ethan Kerzner
Hi,

I am interested in using a geometry shader to do calculations on the GPU but 
instead of drawing the result, it should be piped back into a vertex buffer. 

A high level description of the process is:

1. Load scene and shaders to be used for transform feedback. (I do not know if 
I would load the shaders in an osg::Program, or in my own OpenGL context)

2. Enable shaders, and enable transform feedback to discard the rasterization 
of the GPU pipeline

3. Set up a buffer receive data that would usually be rasterized 
(glTransformFeedbackVaryings, and glBindBufferBase)

4. Draw the scene once

5. The data of interest will be piped into the buffer set up in step 3.


Can you please recommend a good resource for implementing transform feedback in 
osg? Otherwise, could you please recommend a guide to running your own OpenGL 
code inside a program?

Thanks,
Ethan

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





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