Exemplo n.º 1
0
void Stimulus3DShaderDemo::update( const double& time, const osg::Vec3& observer_position, const osg::Quat& observer_orientation )
{
    Poco::NamedMutex::ScopedLock lock(_memlock);
    if (!_slave) {
        char old = *_mem.begin();
      *_mem.begin() = (old % 'z') == 0 ? 'a' : old + 1;
    }
    //std::cerr << *_mem.begin() << "\n";
}
const char* MemoryManager::getData(HashType hashType) {
    if (mem_ptrs.count(hashType) && mem_ptrs[hashType]) {
        throw SharedMemoryException("Try to get unreleased pointer.");
    }
    
    const Poco::File* data_fd = mem_fds[hashType];
    Poco::SharedMemory* data = new Poco::SharedMemory(*data_fd, Poco::SharedMemory::AM_READ);
    mem_ptrs[hashType] = data;
    return data->begin();
}
Exemplo n.º 3
0
void Stimulus3DShaderDemo::post_init(bool slave) {
    osg::ref_ptr<osg::Node> drawn_geometry_node = load_osg_file("Stimulus3DShaderDemo.osg");

    osg::StateSet* state = drawn_geometry_node->getOrCreateStateSet();
    state->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

    osg::Program* AltitudeProgram;
    osg::Shader*  AltitudeVertObj;
    osg::Shader*  AltitudeFragObj;

    AltitudeProgram = new osg::Program;
    AltitudeProgram->setName( "altitude" );
    AltitudeVertObj = new osg::Shader( osg::Shader::VERTEX );
    AltitudeFragObj = new osg::Shader( osg::Shader::FRAGMENT );
    AltitudeProgram->addShader( AltitudeFragObj );
    AltitudeProgram->addShader( AltitudeVertObj );

    load_shader_source( AltitudeVertObj, "rainbow.vert" );
    load_shader_source( AltitudeFragObj, "rainbow.frag" );

    state->setAttributeAndModes(AltitudeProgram, osg::StateAttribute::ON);
    example_param_uniform = new osg::Uniform( osg::Uniform::FLOAT, "example_param" );
    state->addUniform( example_param_uniform );

    _group = new osg::Group;
    _group->addChild(drawn_geometry_node);
    _group->setName("Stimulus3DShaderDemo._group");

    _slave = slave;
    {
      Poco::NamedMutex::ScopedLock lock(_memlock);
      *_mem.begin() = 'a';
    }
}