Hi John,

You need use your own shaders as GLES2 does not support materials or OpenGL
lighting. AFAIK shader generator to emulate fixed pipeline is a work in
progress, but it's not completed yet.

Cheers.

2012/5/27 John Moore <kahar...@gmail.com>

> Hi,
>
> I am developing an application for iPhone and iPod touch using
> OpenSceneGraph. In origin I written my own shaders and I used to control
> light using a uniform. It was working. Now I wanted to switch to use
> osg::Light and osg::LightSource because I think it is more object-oriented,
> but when I run my code I obtain this warning:
>
>
> Code:
> Warning: Light::apply(State&) - not supported.
>
>
>
> Does this mean that I can't use this approach with OpenGL ES 2.0 ?
>
>
> I post the code I use for managing light:
>
>
> Code:
>
> #define LIGHT_0 0
> - (osg::ref_ptr<osg::Light>)createLight:(osg::Vec4)color
> atPosition:(osg::Vec4)position
> {
>    osg::ref_ptr<osg::Light> light = new osg::Light;
>    // each light must have a unique number
>    light->setLightNum(LIGHT_0);
>    // we set the light's position via a PositionAttitudeTransform object
>    light->setPosition(position);
>    light->setDiffuse(color);
>    light->setSpecular(osg::Vec4(1.0, 1.0, 1.0, 1.0));
>    light->setAmbient( osg::Vec4(0.0, 0.0, 0.0, 1.0));
>
>    return light;
>
> }
>
> - (void)setupLights
> {
>
>    osg::StateSet* state = _root->getOrCreateStateSet();
>    state->setMode( GL_LIGHTING, osg::StateAttribute::ON );
>    state->setMode( GL_LIGHT0, osg::StateAttribute::ON );
>
>    // Create a MatrixTransform to position the Light.
>    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
>    osg::Matrix m;
>    m.makeTranslate( osg::Vec3( -3.f, 2.f, 5.f ) );
>    mt->setMatrix( m );
>
>    osg::ref_ptr<osg::Light> light = [self
> createLight:osg::Vec4(1.0,0.0,0.0,1.0)
> atPosition:osg::Vec4(3.0,2.0,1.0,1.0)];
>
>    // Add the Light to a LightSource. Add the LightSource and
>    // MatrixTransform to the scene graph.
>    osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
>    _root->addChild( mt.get() );
>    mt->addChild( ls.get() );
>    ls->setLight( light.get() );
>
> }
>
> - (void) viewDidLoad
> {
>    //some other code
>
>    //initialize the model and attach it to _root
>    [self initModel];
>
>    //setup the lights
>    [self setupLights];
>
>    //initialize the shaders and attach them to _root
>    [self initShaders];
>
>
>    //create scene and attach it to _viewer
>    _viewer->setSceneData(_root.get());
>
>    //some other code
> }
>
>
>
>
>
> Thank you!
>
> Cheers,
> John
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=47877#47877
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jordi Torres Fabra

gvSIG 3D blog
http://gvsig3d.blogspot.com
Instituto de Automática e Informática Industrial
http://www.ai2.upv.es
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to