| 153 | } |
| 154 | |
| 155 | void OverlayEffect::Initialize(int32_t windowWidth, int32_t windowHeight, |
| 156 | int32_t textureWidth, int32_t textureHeight) |
| 157 | { |
| 158 | LogAssert(windowWidth > 0 && windowHeight > 0 && textureWidth > 0 |
| 159 | && textureHeight > 0, "Invalid input rectangle."); |
| 160 | |
| 161 | mInvTextureWidth = 1.0f / static_cast<float>(textureWidth); |
| 162 | mInvTextureHeight = 1.0f / static_cast<float>(textureHeight); |
| 163 | |
| 164 | mOverlayRectangle[0] = 0; |
| 165 | mOverlayRectangle[1] = 0; |
| 166 | mOverlayRectangle[2] = windowWidth; |
| 167 | mOverlayRectangle[3] = windowHeight; |
| 168 | |
| 169 | mTextureRectangle[0] = 0; |
| 170 | mTextureRectangle[1] = 0; |
| 171 | mTextureRectangle[2] = textureWidth; |
| 172 | mTextureRectangle[3] = textureHeight; |
| 173 | |
| 174 | // Create the vertex buffer. |
| 175 | VertexFormat vformat; |
| 176 | vformat.Bind(VASemantic::POSITION, DF_R32G32_FLOAT, 0); |
| 177 | vformat.Bind(VASemantic::TEXCOORD, DF_R32G32_FLOAT, 0); |
| 178 | mVBuffer = std::make_shared<VertexBuffer>(vformat, 4); |
| 179 | mVBuffer->SetUsage(Resource::Usage::DYNAMIC_UPDATE); |
| 180 | UpdateVertexBuffer(); |
| 181 | |
| 182 | // Create the index buffer. |
| 183 | mIBuffer = std::make_shared<IndexBuffer>(IP_TRIMESH, 2, sizeof(uint32_t)); |
| 184 | auto indices = mIBuffer->Get<uint32_t>(); |
| 185 | indices[0] = 0; indices[1] = 2; indices[2] = 3; |
| 186 | indices[3] = 0; indices[4] = 3; indices[5] = 1; |
| 187 | } |
| 188 | |
| 189 | void OverlayEffect::UpdateVertexBuffer() |
| 190 | { |