Updated Image Loading and Displaying Examples (markdown)

omar 2022-02-07 11:59:48 +01:00
parent e3c48d1ac8
commit da9bf6d793

@ -553,17 +553,18 @@ ImGui::Text("uv1 = (%f, %f)", uv1.x, uv1.y);
ImGui::Image((void*)(intptr_t)my_image_texture, ImVec2(100.0f, 200.0f), uv0, uv1); ImGui::Image((void*)(intptr_t)my_image_texture, ImVec2(100.0f, 200.0f), uv0, uv1);
``` ```
Same code written differently: Same code written differently, with named variables:
```cpp ```cpp
ImVec2 display_min = ImVec2(10.0f, 10.0f); ImVec2 display_min = ImVec2(10.0f, 10.0f);
ImVec2 display_size = ImVec2(100.0f, 200.0f); ImVec2 display_size = ImVec2(100.0f, 200.0f);
ImVec2 texture_size = ImVec2(256.0f, 256.0f);
// Normalized coordinates of pixel (10,10) in a 256x256 texture. // Normalized coordinates of pixel (10,10) in a 256x256 texture.
ImVec2 uv0 = ImVec2(display_min.x / 256.0f, display_min.y / 256.0f); ImVec2 uv0 = ImVec2(display_min.x / texture_size.x, display_min.y / texture_size.y);
// Normalized coordinates of pixel (110,210) in a 256x256 texture. // Normalized coordinates of pixel (110,210) in a 256x256 texture.
ImVec2 uv1 = ImVec2((display_min.x + display_size.x) / 256.0f, (display_min.y + display_size.y) / 256.0f); ImVec2 uv1 = ImVec2((display_min.x + display_size.x) / texture_size.x, (display_min.y + display_size.y) / texture_size.y);
ImGui::Text("uv0 = (%f, %f)", uv0.x, uv0.y); ImGui::Text("uv0 = (%f, %f)", uv0.x, uv0.y);
ImGui::Text("uv1 = (%f, %f)", uv1.x, uv1.y); ImGui::Text("uv1 = (%f, %f)", uv1.x, uv1.y);