extrawurst / DerelictImgui

Dynamic bindings to the cimgui library (a c-api for IMGUI) for the D programming language
MIT License
54 stars 13 forks source link

igImage showing wrong image, igImageButton is completely white. #5

Closed zeyonaut closed 8 years ago

zeyonaut commented 8 years ago

Steps to reproduce: Be on Mac OS X 10.11. Install dub dependency imageformats and import it into imgui_d_test (your repo). Before void main:

GLuint tex = 0; 
IFImage im;

After initialization:

im = read_image("/Users/Home/whatever.png", 4);
    glGenTextures(1, &tex);
    glBindTexture(GL_TEXTURE_2D, tex);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cast(int)im.w, cast(int)im.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, &im.pixels);

Then, in a window, igImage( &tex, ImVec2(im.w, im.h), ImVec2(0,0), ImVec2(1,1), ImVec4(255,255,255,255), ImVec4(255,255,255,0)); (Or appropriate igImageButton call.)

Then, you shall get what I describe in my title: Instead of the actual image, it shows the image of the embedded font in ImGui. If it is a button, you just get a blank white button.

screen shot 2016-03-21 at 8 26 32 pm

Would you mind fixing this? I have no idea why this could be. Any help would be very much appreciated.

extrawurst commented 8 years ago

What you try to achieve is exactly what i am doing here: https://github.com/Extrawurst/unecht/blob/master/screenshots/2016-02-13%20dragdrop.gif

it is working as u see. i would investigate your drawing code (where textures are bound) and the image format should also match and you should check glError to find out if there is something going wrong

zeyonaut commented 8 years ago

Thanks for the response.

I was skeptical at first that the drawing code was going wrong. However, when I tried to replicate it in C++, the same thing happened! I'm using your ImGui-GLFW implementation file, which was, obviously, a port of the original ImGuiImpl for GLFW3. The texture binding is done in the same way as the font is. I might try editing the implementation file to give ImGui a different texture and check glError.

Edit: You're right, something's wrong with my drawing code. Thanks for the tips.

You have no idea how grateful I am for this. I didn't think of looking in the draw code, but I did not realize I had changed it. Still, thank you so much!

~ Aaron.