void CameraBuffer::execute(DataProvider& provider) { // get the input data Id2DataPair inputMapper(INPUT); provider.receiveInputData(inputMapper); // try to get a free buffer Data* buffer = 0; try { buffer = m_buffers(0); } catch(Timeout&) { } if(buffer) { // there was a free buffer DataContainer bufferContainer(buffer); // remember it in the recycling access m_buffers.add(bufferContainer); Id2DataPair outputMapper(OUTPUT, inputMapper.data()); Id2DataPair bufferMapper(BUFFER, bufferContainer); Id2DataPair idMapper(INDEX, DataContainer(new UInt32(m_id))); // send it to the output (together with the input image and the current index) provider.sendOutputData(outputMapper && bufferMapper && idMapper); } // increase the index ++m_id; }
void Send::execute(DataProvider& provider) { Id2DataPair inputMapper(INPUT); provider.receiveInputData(inputMapper); m_server->send(inputMapper.data()); }
void Add::execute(runtime::DataProvider& provider) { runtime::Id2DataPair inputMapper(INPUT); provider.receiveInputData(inputMapper); runtime::ReadAccess input(inputMapper.data()); unsigned int sum = (unsigned int)(input.get<runtime::UInt32>()) + (unsigned int)(m_offset); runtime::Data* result = new runtime::UInt32(sum); runtime::DataContainer outContainer(result); runtime::Id2DataPair output(OUTPUT, outContainer); provider.sendOutputData(output); }
void DebugDrawer::DrawTangents(const StaticMesh* subMesh) { if (!s_initialized && !Initialize()) { NazaraError("Failed to initialize Debug Drawer"); return; } unsigned int tangentCount = subMesh->GetVertexCount(); unsigned int vertexCount = tangentCount*2; if (s_vertexBuffer.GetVertexCount() < vertexCount) { NazaraError("Debug buffer not large enougth to draw object"); return; } BufferMapper<VertexBuffer> inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly); BufferMapper<VertexBuffer> outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount); MeshVertex* inputVertex = reinterpret_cast<MeshVertex*>(inputMapper.GetPointer()); VertexStruct_XYZ* outputVertex = reinterpret_cast<VertexStruct_XYZ*>(outputMapper.GetPointer()); for (unsigned int i = 0; i < tangentCount; ++i) { outputVertex->position = inputVertex->position; outputVertex++; outputVertex->position = inputVertex->position + inputVertex->tangent*0.01f; outputVertex++; inputVertex++; } inputMapper.Unmap(); outputMapper.Unmap(); if (vertexCount > 0) { Renderer::SetRenderStates(s_renderStates); Renderer::SetShader(s_shader); Renderer::SetVertexBuffer(&s_vertexBuffer); s_shader->SendColor(s_colorLocation, s_primaryColor); Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, vertexCount); } }