Ejemplo n.º 1
0
int main(int argc, char* argv[])
{
    osg::ref_ptr<osg::Group> root(new osg::Group);
    osg::ref_ptr<osg::Geode> sphere(build_sphere());
    root->addChild(sphere.get());

    osg::ref_ptr<osg::Light> light(new osg::Light);
    light->setLightNum(1);
    light->setPosition(osg::Vec4(0., 0., 0., 1.));
    osg::ref_ptr<osg::LightSource> light_source(new osg::LightSource);
    light_source->setLight(light.get());
    osg::ref_ptr<osg::MatrixTransform> transform(new osg::MatrixTransform);
    transform->addChild(light_source.get());
    osg::Matrix matrix;
    matrix.makeTranslate(osg::Vec3(10., 0., 0.));
    transform->setMatrix(matrix);
    root->addChild(transform.get());

    boost::shared_ptr<shade::GLSLWrapper> state(new shade::osg::Wrapper(sphere->getOrCreateStateSet()));

    boost::shared_ptr<shade::Program> shader_program(setup_shading(state));
    shader_program->compile();
    state->make_current();
    shader_program->upload();

    run_viewer(root.get());
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
  osg::ref_ptr<osg::Geode> quad(build_quad());

  osg::ref_ptr<osg::Image> image = osgDB::readImageFile("examples/pattern.dds");
  osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D;
  tex->setImage(image.get());
  boost::shared_ptr<shade::osg::Texture> shade_tex(new shade::osg::Texture(tex.get()));

  boost::shared_ptr<shade::GLSLWrapper> state(new shade::osg::Wrapper(quad->getOrCreateStateSet()));

  boost::shared_ptr<shade::Program> shader_program(setup_shading(state, shade_tex));
  shader_program->compile();
  state->make_current();
  shader_program->upload();

  run_viewer(quad.get());
}