Black square when using ImGui::Image

Hi, Im very sure its not a bug but i am making some dump mistake somewhere.
With the 2 example codes (1 from getting started and 1 for the image) im trying to get to display some image (wikipedia in this case so i can upload it to github).

The code is here: https://github.com/SimiPro/imgui_image_test
you can run it simply with mkdir build, cd build, cmake … (after cloning with git clone --recursive-submodules)

It only displays a black square. The whole code is in main.cpp

In CMakeLists.txt you see that I use the following backend code:
“imgui/examples/imgui_impl_glfw.h”
“imgui/examples/imgui_impl_opengl3.h”
“imgui/examples/imgui_impl_glfw.cpp”
“imgui/examples/imgui_impl_opengl3.cpp”
“imgui/examples/libs/gl3w/GL/gl3w.c”
“imgui/examples/libs/gl3w/GL/gl3w.h”
“imgui/examples/libs/gl3w/GL/glcorearb.h”

Any help appreciated. :slight_smile:

Sorry to bother you.

Code looks correct, maybe use a debugger to make sure your image data is correctly loaded (path, format etc.). A common problem people have is that the relative path is incorrect because the executable is not started from the working directory they expect.

So i figured it out. I needed to add: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
to my texture as configuration. Instead of // glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
Thanks for the help!

1 Like