//-------------------------------------------------------------------------------// void OverlayPanelElement::updateGeometryData() { /* 0-----2 | /| | / | |/ | 1-----3 */ Renderer* renderer = Root::getSingleton().getActiveRenderer(); float offsetLeft = mLeft + renderer->getHorizontalTexelOffset() / OverlayMgr::getSingleton().getViewportWidth(); float offsetTop = mTop + renderer->getVerticalTexelOffset() / OverlayMgr::getSingleton().getViewportHeight(); float left, right, top, bottom; left = offsetLeft * 2 - 1; right = left + mWidth * 2; top = -((offsetTop * 2) - 1); bottom = top - mHeight * 2; VertexBufferPtr vbuf = mRenderData.vertexData->vertexBufferBinding->getBuffer(0); float* pPos = static_cast<float*>(vbuf->lock(HardwareBuffer::HBL_DISCARD)); float zValue = Root::getSingleton().getActiveRenderer()->getMaxDepthValue(); *pPos++ = left; *pPos++ = top; *pPos++ = zValue; *pPos++ = left; *pPos++ = bottom; *pPos++ = zValue; *pPos++ = right; *pPos++ = top; *pPos++ = zValue; *pPos++ = right; *pPos++ = bottom; *pPos++ = zValue; vbuf->unlock(); }
//-------------------------------------------------------------------------------// void OverlayPanelElement::updateTexData() { if(!mTexture.isNull() &&mIsInitialised) { VertexDeclaration* decl = mRenderData.vertexData->vertexDecl; if(mTexCoordNum == 0) { decl->addElement(1, 0,VET_FLOAT2, VES_TEXTURE_COORDINATES, 0); VertexBufferPtr vbuf = HardwareBufferMgr::getSingletonPtr()->createVertexBuffer(decl->getVertexSize(1), mRenderData.vertexData->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); mRenderData.vertexData->vertexBufferBinding->setBinding(1,vbuf); mTexCoordNum = 1; } if(mTexCoordNum) { VertexBufferPtr buf = mRenderData.vertexData->vertexBufferBinding->getBuffer(1); float* pVBStart = static_cast<float*>(buf->lock(HardwareBuffer::HBL_DISCARD)); size_t uvSize = VertexElement::getTypeSize(VET_FLOAT2) / sizeof(float); size_t vertexSize = decl->getVertexSize(1) / sizeof(float); float* pTex = pVBStart; pTex[0] = mU1; pTex[1] = mV1; pTex += vertexSize; pTex[0] = mU1; pTex[1] = mV2; pTex += vertexSize; pTex[0] = mU2; pTex[1] = mV1; pTex += vertexSize; pTex[0] = mU2; pTex[1] = mV2; buf->unlock(); } } }