Re: [osg-users] How to setup and confirm a proper forward-compatipble GL3 context

2011-10-07 Thread PP CG

Hi J-S,

thank you for your answer, and sorry my late response, was without 
connection for some time.


I activated the uniforms, but still the uniforms don't get printed 
through my update callback.
When I activate these uniforms, does this mean at all that they should 
be get in any StateSet of any Node ? I think they should, as otherwise I 
couldn't use them, right ?


Does anybody else tell me how I can create and confirm a proper GL3 
context ?


Thank you,

Cheers, PP


Hi Peter,

I don't know about your other questions about the GL 3 context, but I 
can answer this since I've been looking at it recently.



How do I get these default osg_ Uniforms into the StateSet ? The only
place where I find code for creaating them is osgUtil::SceneView, which
is marked as deprecated.


See the osgvertexattributes example, there you will see that you need 
to do:


  context-getState()-setUseModelViewAndProjectionUniforms(true);

once you've created your context. You'll probably also need

  context-getState()-setUseVertexAttributeAliasing(true);

Though I'm not sure exactly what it does.

Search in the OSG sources for getUseModelViewAndProjectionUniforms() 
and getUseVertexAttributeAliasing() and you'll see where they are used 
to create and update the uniforms / variables.


Hope this helps,

J-S


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


Re: [osg-users] How to setup and confirm a proper forward-compatipble GL3 context

2011-10-07 Thread Jean-Sébastien Guay

Hi Peter,


I activated the uniforms, but still the uniforms don't get printed
through my update callback.
When I activate these uniforms, does this mean at all that they should
be get in any StateSet of any Node ? I think they should, as otherwise I
couldn't use them, right ?


No, they get pushed into the state by the SceneView and other internal 
classes, so it's very possible that you'll never see them in any 
StateSet. As I said before:


 Search in the OSG sources for getUseModelViewAndProjectionUniforms()
 and getUseVertexAttributeAliasing() and you'll see where they are used
 to create and update the uniforms / variables.

Hope this helps,

J-S
--
__
Jean-Sébastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to setup and confirm a proper forward-compatipble GL3 context

2011-10-07 Thread PP CG

Hi J-S,

thanks for your reply, that makes sense and helps.

I'll try to ask the community about the GL3 context in another topic if 
nobody answers here anymore. Maybe this will solve the other issues.


Cheers, PP


Hi Peter,


I activated the uniforms, but still the uniforms don't get printed
through my update callback.
When I activate these uniforms, does this mean at all that they should
be get in any StateSet of any Node ? I think they should, as otherwise I
couldn't use them, right ?


No, they get pushed into the state by the SceneView and other internal 
classes, so it's very possible that you'll never see them in any 
StateSet. As I said before:


 Search in the OSG sources for getUseModelViewAndProjectionUniforms()
 and getUseVertexAttributeAliasing() and you'll see where they are used
 to create and update the uniforms / variables.

Hope this helps,

J-S


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


[osg-users] How to setup and confirm a proper forward-compatipble GL3 context

2011-09-30 Thread Peter Wrobel

Hi, I have some doubts about my approach to create a GL3 non FFP context.

I have compiled osg with all the cmake settings for GL3 as explained in 
lots of other posts.
When I create an object ( a simple two Vertex line ), usual camera 
manipulation is working without me having writrten a single shader for 
the vertex tranform. I expect this not to work, is this wrong ?
The geode is a child of a osg::PositionAttitudeTransform with a rotation 
UpdateCallback. This also works, but it shouldn't without Shaders, right ?
Moreover, I create a StateSet for the Transform and give it 
osg::StateSet::Callback to print all uniforms, no osg_ Uniforms ( e.g. 
osg_ViewMatrix ) get printed out. Is it possible that all this works 
without FFP ? I guess not.
How do I get these default osg_ Uniforms into the StateSet ? The only 
place where I find code for creaating them is osgUtil::SceneView, which 
is marked as deprecated.


As the glContextVersion of the GraphicsContext attached to the default 
camera in the default viewer is 1.0, I use this way I set up the GL3 
Context.
Please correct me if there is a better way, and if this does creat the 
required context at all.


osg::GraphicsContext::Traits * traits = new 
osg::GraphicsContext::Traits() ;


int width = 1920 , height = 1200 ;
traits - x = 0 ;
traits - y = 0 ;
traits - width  = width ;
traits - height = height ;
traits - windowDecoration = false ;
traits - doubleBuffer = true ;
traits - glContextVersion = std::string( 3.3 ) ;

osg::Camera * cam = new osg::Camera() ;
cam - setGraphicsContext( 
osg::GraphicsContext::createGraphicsContext( traits ) ) ;

cam - setViewport( 0 , 0 , width , height ) ;
cam - setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
cam - setClearColor( osg::Vec4( 0.0 , 0.0 , 0.0 , 1.0 ) ) ;
cam - setProjectionMatrixAsPerspective( 30.0f , ( float )width / ( 
float )height , 1.0 , 1000.0 ) ;


viewer.setCamera( cam ) ;

// This Line::get() is defined bellow
viewer.setSceneData( Line::get() ) ;


This is the code for the callbacks and the Geometry, as mentined, 
no Shaders attached, so why does Transformation work ?


class CBSS_Line : public osg::StateSet::Callback  {

void operator()( osg::StateSet * stateSet , osg::NodeVisitor * 
nodeVisitor )  {
const osg::StateSet::UniformList  uniformList = stateSet - 
getUniformList() ;


for(osg::StateSet::UniformList::const_iterator uitr = 
uniformList.begin() ;

uitr != uniformList.end() ; ++uitr )  {

std::cout  uitr - first  std::endl ;
}
}
} ;



class CBN_Line : public osg::NodeCallback  {

void operator()( osg::Node * node , osg::NodeVisitor * nodeVisitor 
)  {
osg::PositionAttitudeTransform * xform = static_cast  
osg::PositionAttitudeTransform * ( node ) ;
xform - setAttitude( osg::Quat( nodeVisitor - getFrameStamp() 
- getSimulationTime() * osg::PI , osg::Z_AXIS ) ) ;

traverse( node , nodeVisitor ) ;
}

} ;


class Line  {

public :
static osg::Node * get()  {

osg::ref_ptr osg::PositionAttitudeTransform  xformLine = new 
osg::PositionAttitudeTransform() ;

xformLine - addUpdateCallback( new CBN_Line ) ;
xformLine - getOrCreateStateSet() - setUpdateCallback( new 
CBSS_Line ) ;


osg::ref_ptr osg::Geode  geodeLine = new osg::Geode() ;
xformLine - addChild( geodeLine.get() ) ;

osg::Geometry * geomLine = new osg::Geometry() ;
geodeLine - addDrawable( geomLine ) ;

osg::Vec3Array * vrts = new osg::Vec3Array() ;
geomLine - setVertexArray( vrts ) ;

osg::Vec4Array * rgba = new osg::Vec4Array() ;
geomLine - setColorArray( rgba ) ;
geomLine - setColorBinding( osg::Geometry::BIND_OVERALL ) ;

vrts - push_back( osg::Vec3( 0.0f , 0.0f , 0.0f ) ) ;
vrts - push_back( osg::Vec3( 1.0f , 0.0f , 0.0f ) ) ;
rgba - push_back( osg::Vec4( 1.0f , 0.0f , 0.0f , 1.0f ) ) ;

geomLine - addPrimitiveSet( new osg::DrawArrays( 
osg::PrimitiveSet::LINES , 0 , 2 ) ) ;


osg::StateSet * stateSet = xformLine - getOrCreateStateSet() ;
stateSet - setAttributeAndModes( new osg::LineWidth( 5.0f ) ) ;
stateSet - setMode( GL_LIGHTING , osg::StateAttribute::OFF ) ;

// Adding an Uniform to test the osg::StateSet::Callback 
printing function

stateSet - addUniform( new osg::Uniform( Time , 0.0f  ) ) ;

// Not created this shader so far
//osg::Program * program = new osg::Program ;
//program - addShader( osgDB::readShaderFile( 
shader/Line.vert ) ) ;
//program - addShader( osgDB::readShaderFile( 
shader/Line.frag ) ) ;
//stateSet - setAttributeAndModes( program , 
osg::StateAttribute::ON ) ;


return xformLine.release() ;
}

} ;


Thank you,

Cheers, PP



___
osg-users mailing list

Re: [osg-users] How to setup and confirm a proper forward-compatipble GL3 context

2011-09-30 Thread Jean-Sébastien Guay

Hi Peter,

I don't know about your other questions about the GL 3 context, but I 
can answer this since I've been looking at it recently.



How do I get these default osg_ Uniforms into the StateSet ? The only
place where I find code for creaating them is osgUtil::SceneView, which
is marked as deprecated.


See the osgvertexattributes example, there you will see that you need to do:

  context-getState()-setUseModelViewAndProjectionUniforms(true);

once you've created your context. You'll probably also need

  context-getState()-setUseVertexAttributeAliasing(true);

Though I'm not sure exactly what it does.

Search in the OSG sources for getUseModelViewAndProjectionUniforms() and 
getUseVertexAttributeAliasing() and you'll see where they are used to 
create and update the uniforms / variables.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org