Imgui: How to draw an .png file into a ImGui window

Created on 10 Dec 2017  路  3Comments  路  Source: ocornut/imgui

Uhh yeah im trying to draw a image but i have no idea

ImTextureID my_tex_id = io.Fonts->TexID;

float my_tex_w = (float)io.Fonts->TexWidth;

float my_tex_h = (float)io.Fonts->TexHeight;

ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));

Just copy and pasted the example from imgui_demo but how can i change the ImTextureId to a png?

ImTextureID my_tex_id = "D:\DL\_SHIT\xd.JPG";

doesnt work

Most helpful comment

I have now written a tutorial to cover image file loading for common graphics API:
https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples

All 3 comments

Turning an image into a graphics textures it out of scope of imgui, it's up to your back end code. Please read about OpenGL / DirectX texture loading, whatever graphics backend you are using. Also please read the documentation about ImTextureId and browse/run the demo window code.

k

I have now written a tutorial to cover image file loading for common graphics API:
https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mnemode2 picture mnemode2  路  3Comments

inflex picture inflex  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

DarkLinux picture DarkLinux  路  3Comments

mkanakis picture mkanakis  路  3Comments