From 701e63aa56ce63997cf48dbd078eda6372ee03b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hinko=20Ko=C4=8Devar?= Date: Wed, 23 Sep 2020 10:23:23 +0200 Subject: [PATCH] Make example code consistent with the example text, use the same variable names, provide example code that will yield the result in the pics --- Image-Loading-and-Displaying-Examples.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Image-Loading-and-Displaying-Examples.md b/Image-Loading-and-Displaying-Examples.md index 0a4baac..0eca849 100644 --- a/Image-Loading-and-Displaying-Examples.md +++ b/Image-Loading-and-Displaying-Examples.md @@ -527,8 +527,11 @@ ImVec2 uv0 = ImVec2(10.0f/256.0f, 10.0f/256.0f); // Normalized coordinates of pixel (110,210) in a 256x256 texture. ImVec2 uv1 = ImVec2((10.0f+100.0f)/256.0f, (10.0f+200.0f)/256.0f); -// Display the 100x100 section starting at (10,10) -ImGui::Image((void*)texture, ImVec2(100.0f, 100.0f), uv0, uv1); +ImGui::Text("uv0 = (%f, %f)", uv0.x, uv0.y); +ImGui::Text("uv1 = (%f, %f)", uv1.x, uv1.y); + +// Display the 100x200 section starting at (10,10) +ImGui::Image((void*)(intptr_t)my_image_texture, ImVec2(100.0f, 200.0f), uv0, uv1); ``` ![Using UV](https://user-images.githubusercontent.com/8225057/79073825-f9988280-7ce8-11ea-8596-1fd495720ffa.png) @@ -540,10 +543,10 @@ If you want to display the same image but scaled, keep the same UV coordinates b ```cpp // Normal size -ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f)); +ImGui::Image((void*)(intptr_t)my_image_texture, ImVec2(my_image_width, my_image_height), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f)); // Half size, same contents -ImGui::Image((void*)texture, ImVec2(texture->Width*0.5f, texture->Height*0.5f), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f)); +ImGui::Image((void*)(intptr_t)my_image_texture, ImVec2(my_image_width*0.5f, my_image_height*0.5f), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f)); ``` ![Scaled](https://user-images.githubusercontent.com/8225057/79073856-25b40380-7ce9-11ea-91e4-754c3232fb58.png)