void DrawOutdent(const float size[2], Graphics::RenderState *state) { PROFILE_SCOPED() // locals RefCountedPtr<Graphics::VertexBuffer> vb; RefCountedPtr<Graphics::IndexBuffer> ib[3]; // see if we have this size of indent in the cache already const vector2f vsize(size[0], size[1]); MapOutdentBuffers::iterator bufIt = s_outdentBuffers.find(vsize); if (bufIt != s_outdentBuffers.end()) { // found it vb = bufIt->second.vb; ib[0] = bufIt->second.ib[0]; ib[1] = bufIt->second.ib[1]; ib[2] = bufIt->second.ib[2]; } else { // generate it const vector3f vertices[] = { /* 0 */ vector3f(0, 0, 0), /* 1 */ vector3f(0, size[1], 0), /* 2 */ vector3f(size[0], size[1], 0), /* 3 */ vector3f(size[0], 0, 0), /* 4 */ vector3f(BORDER_WIDTH, BORDER_WIDTH, 0), /* 5 */ vector3f(BORDER_WIDTH, size[1] - BORDER_WIDTH, 0), /* 6 */ vector3f(size[0] - BORDER_WIDTH, size[1] - BORDER_WIDTH, 0), /* 7 */ vector3f(size[0] - BORDER_WIDTH, BORDER_WIDTH, 0) }; const Uint32 indices[] = { 0, 1, 5, 0, 5, 4, 0, 4, 7, 0, 7, 3, 3, 7, 6, 3, 6, 2, 1, 2, 6, 1, 6, 5, 4, 5, 6, 4, 6, 7 }; // create buffer Graphics::VertexBufferDesc vbd; vbd.attrib[0].semantic = Graphics::ATTRIB_POSITION; vbd.attrib[0].format = Graphics::ATTRIB_FORMAT_FLOAT3; vbd.numVertices = 8; vbd.usage = Graphics::BUFFER_USAGE_STATIC; // Upload data vb.Reset(Screen::GetRenderer()->CreateVertexBuffer(vbd)); TPos* vtxPtr = vb->Map<TPos>(Graphics::BUFFER_MAP_WRITE); assert(vb->GetDesc().stride == sizeof(TPos)); for (Uint32 i = 0; i < 8; i++) { vtxPtr[i].pos = vertices[i]; } vb->Unmap(); // indices Uint32 IndexStart = 0; Uint32 IndexEnd = 12; Uint32 NumIndices = 12; ib[0].Reset(CreateIndexBuffer(indices, IndexStart, IndexEnd, NumIndices)); IndexStart += NumIndices; NumIndices = 12; IndexEnd += NumIndices; ib[1].Reset(CreateIndexBuffer(indices, IndexStart, IndexEnd, NumIndices)); IndexStart += NumIndices; NumIndices = 6; IndexEnd += NumIndices; ib[2].Reset(CreateIndexBuffer(indices, IndexStart, IndexEnd, NumIndices)); TOutdentBuffers tib; tib.vb = vb; tib.ib[0] = ib[0]; tib.ib[1] = ib[1]; tib.ib[2] = ib[2]; s_outdentBuffers[vsize] = tib; } // Draw it! Screen::flatColorMaterial->diffuse = Color(153,153,153,255); Screen::GetRenderer()->DrawBufferIndexed(vb.Get(), ib[0].Get(), state, Screen::flatColorMaterial); Screen::flatColorMaterial->diffuse = Colors::bgShadow; Screen::GetRenderer()->DrawBufferIndexed(vb.Get(), ib[1].Get(), state, Screen::flatColorMaterial); Screen::flatColorMaterial->diffuse = Colors::bg; Screen::GetRenderer()->DrawBufferIndexed(vb.Get(), ib[2].Get(), state, Screen::flatColorMaterial); }