Hi Eldar,

You need to call viewer.realize() to create the windows otherwise the
Camera won't haven't anything assigned yet.

In your example code viewer.run() will be calling viewer.realize() for
you unless you've already done so, so as it stands your example code
won't have any windows and hence graphics contexts created when you
attempt to get the State object.

Robert.

On 4 April 2012 12:33, Eldar Insafutdinov <[email protected]> wrote:
> Hi
>
> I switched to using osg_* variables in my shaders instead of built-in gl_* in 
> order to comply with with OpenGL 3.x/ OpenGL ES 2.0. However it doesn't seem 
> to work for me I found that it's managed by the State class, and I can obtain 
> the state object from the GraphicsContext. however a code like this doesn't 
> work:
>
>
> Code:
>
> int main()
> {
>    osgViewer::Viewer viewer;
>    viewer.setSceneData(new MyCustomNode());
>
>    osg::State* state = viewer.getCamera()->getGraphicsContext()->getState();
>    state->setUseModelViewAndProjectionUniforms(true);
>    state->setUseVertexAttributeAliasing(true);
>    return viewer.run();
> }
>
>
>
>
> The problem is that viewer.getCamera()->getGraphicsContext() return 0, 
> suggesting that I have to setup one myself. But I will need to provide width 
> and height and other parameters, which I don't really want to do, because 
> they are unrelevant and I didn't have to do that before. Is there a way to 
> get the default GraphicsContext instance, as I just need to set the 
> parameters for shaders?
>
> Cheers,
>
> Eldar
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=46791#46791
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to