示例#1
0
void AgentMover::getAgents(std::vector<Agent>& agentsVector) const
{
    // Accessing shared buffer through OpenGL or else content would go random when acquiring the buffer with OpenCL lateron.

    BuffersMapping mapping = mapBuffers(GL_READ_ONLY);

    std::vector<Agent>::iterator iter;

    size_t i = 0;

    for (iter = agentsVector.begin(); iter != agentsVector.end(); ++iter)
    {
        (*iter).position        = mapping.positions[i];
        (*iter).direction       = mapping.directions[i];
        (*iter).speed           = mapping.speeds[i];
        (*iter).maximumSpeed    = mapping.maximumSpeeds[i];
        (*iter).radius          = mapping.radii[i];
        (*iter).id              = mapping.ids[i];
        (*iter).turnRate        = mapping.turnRates[i];

        i++;
    }

    unmapBuffers();
}
示例#2
0
NaoCamera::~NaoCamera()
{
  stopCapturing();
  unmapBuffers();

  close(fd);
}
示例#3
0
void AgentMover::setAgents(const std::vector<Agent>& agentsVector)
{
    if (agentsVector.size() != count)
    {
        throw Exception("AgentMover::setAgents: number of agents does not match previously set count");
    }

    // Accessing shared buffer through OpenGL or else content would go random when acquiring the buffer with OpenCL lateron.

    BuffersMapping mapping = mapBuffers(GL_WRITE_ONLY);

    std::vector<Agent>::const_iterator iter;

    size_t i = 0;

    for (iter = agentsVector.begin(); iter != agentsVector.end(); ++iter)
    {
        mapping.positions[i]      = (*iter).position;
        mapping.directions[i]     = (*iter).direction;
        mapping.speeds[i]         = (*iter).speed;
        mapping.maximumSpeeds[i]  = (*iter).maximumSpeed;
        mapping.radii[i]          = (*iter).radius;
        mapping.ids[i]            = (*iter).id;
        mapping.turnRates[i]      = (*iter).turnRate;

        i++;
    }

    unmapBuffers();
}
bool V4Linux2Camera::closeCamera() {

    if (dev_handle >= 0) {
	updateSettings();
        if (buffers_initialized) unmapBuffers();
        close(dev_handle);

        return true;
    } else return false;

}