| 242 | |
| 243 | |
| 244 | void WindowSplash::fullFrame() { |
| 245 | if (m_window == nullptr) |
| 246 | return; |
| 247 | |
| 248 | glfwSetWindowSize(m_window, WindowSize.x, WindowSize.y); |
| 249 | centerWindow(m_window); |
| 250 | |
| 251 | glfwPollEvents(); |
| 252 | |
| 253 | // Start a new ImGui frame |
| 254 | ImGui_ImplOpenGL3_NewFrame(); |
| 255 | ImGui_ImplGlfw_NewFrame(); |
| 256 | ImGui::NewFrame(); |
| 257 | |
| 258 | // Draw the splash screen background |
| 259 | auto drawList = ImGui::GetBackgroundDrawList(); |
| 260 | { |
| 261 | |
| 262 | // Draw the splash screen background |
| 263 | drawList->AddImage(m_splashBackgroundTexture, ImVec2(0, 0), WindowSize); |
| 264 | |
| 265 | { |
| 266 | |
| 267 | // Function to highlight a given number of bytes at a position in the splash screen |
| 268 | const auto highlightBytes = [&](ImVec2 start, size_t count, ImColor color, float opacity) { |
| 269 | // Dimensions and number of bytes that are drawn. Taken from the splash screen image |
| 270 | const auto hexSize = ImVec2(29, 18); |
| 271 | const auto hexSpacing = ImVec2(17.4F, 15); |
| 272 | const auto hexStart = ImVec2(27, 127); |
| 273 | |
| 274 | constexpr auto HexCount = ImVec2(13, 7); |
| 275 | |
| 276 | color.Value.w *= opacity; |
| 277 | |
| 278 | // Loop over all the bytes on the splash screen |
| 279 | for (u32 y = u32(start.y); y < u32(HexCount.y); y += 1) { |
| 280 | bool isStart = true; |
| 281 | for (u32 x = u32(start.x); x < u32(HexCount.x); x += 1) { |
| 282 | if (count-- == 0) |
| 283 | return; |
| 284 | |
| 285 | // Find the start position of the byte to draw |
| 286 | auto pos = hexStart + ImVec2(float(x), float(y)) * (hexSize + hexSpacing); |
| 287 | |
| 288 | // Fill the rectangle in the byte with the given color |
| 289 | drawList->AddRectFilled(pos + ImVec2(0, -hexSpacing.y / 2), pos + hexSize + ImVec2(0, hexSpacing.y / 2), color); |
| 290 | |
| 291 | // Add some extra color on the right if the current byte isn't the last byte, and we didn't reach the right side of the image |
| 292 | if (count > 0 && x != u32(HexCount.x) - 1) |
| 293 | drawList->AddRectFilled(pos + ImVec2(hexSize.x, -hexSpacing.y / 2), pos + hexSize + ImVec2(hexSpacing.x, hexSpacing.y / 2), color); |
| 294 | |
| 295 | // Add some extra color on the left if this is the first byte we're highlighting |
| 296 | if (isStart) { |
| 297 | isStart = false; |
| 298 | drawList->AddRectFilled(pos - hexSpacing / 2, pos + ImVec2(0, hexSize.y + hexSpacing.y / 2), color); |
| 299 | } |
| 300 | |
| 301 | // Add some extra color on the right if this is the last byte |
no test coverage detected