static inline void CopyPos(Graphics::VertexBuffer *vb, const Graphics::VertexArray &va) { PosVert* vtxPtr = vb->Map<PosVert>(Graphics::BUFFER_MAP_WRITE); assert(vb->GetDesc().stride == sizeof(PosVert)); for(Uint32 i=0 ; i<va.GetNumVerts() ; i++) { vtxPtr[i].pos = va.position[i]; } vb->Unmap(); }
void CopyPosColUV0(Graphics::VertexBuffer *vb, const Graphics::VertexArray &va) { PosColUVVert* vtxPtr = vb->Map<PosColUVVert>(Graphics::BUFFER_MAP_WRITE); assert(vb->GetDesc().stride == sizeof(PosColUVVert)); for(Uint32 i=0 ; i<va.GetNumVerts() ; i++) { vtxPtr[i].pos = va.position[i]; vtxPtr[i].col = va.diffuse[i]; vtxPtr[i].uv = va.uv0[i]; } vb->Unmap(); }
void Disk::SetupVertexBuffer(const Graphics::VertexArray& vertices, Graphics::Renderer *r) { PROFILE_SCOPED() //Create vtx & index buffers and copy data VertexBufferDesc vbd; vbd.attrib[0].semantic = ATTRIB_POSITION; vbd.attrib[0].format = ATTRIB_FORMAT_FLOAT3; vbd.numVertices = vertices.GetNumVerts(); vbd.usage = BUFFER_USAGE_STATIC; m_vertexBuffer.reset(r->CreateVertexBuffer(vbd)); m_vertexBuffer->Populate(vertices); }