New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageButton - white empty rectangle - why ? #521
Comments
Looking at the code in the header file IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding It looks like the UV range is |
It could be because SetTexture is expecting a texture pointer and not an
id. The ID could be used as a lookup in a map or similar structure.
I am not familiar enough with using D3D or textures in imgui to be 100%.
|
I tried it with the default UV values, same result, and also (without any idea what else I could do anymore) with the image size itself, like in the few lines of code I wrote above. Same white rectangle. :( I can make the rectangle BLACK when I set the last arg, the "tin_col" to ImVec4(0,0,0,255)....not that it helps me in anyway, but maybe someone has an idea. The pTexture, which I pass as (void*) to the ImageButton function is correct afaik, it uses the pointer as "ID". If anyone has a running working texture loaded, maybe he could post a code snippet, so I know what i have to do in order to get this to work ? |
If I use the already existing it shows this texture.... but not the one(s) loaded from a file ...am I missing any steps in loading a texture from a file or why is it so much not showing anything -.- ? |
Show us your code!
|
imgui.cpp:
And the function where I call imgui:Image for drawing the image:
This is what gets drawn, I can color the "own texture" boxes to whatever color I want by changin the tin_col argument in the ImageButton() function. it is like the alpha is not working and it always draws the color ontop...or maybe it is normal that the color is drawn first and the texture later ontop ? sadly I have no idea how this "usually" works. |
Try opening the metrics window and confirm the texture id in the different draw calls. |
This is while hovering with the mouse over the topmost white rectangle: This is while hovering over the first "Draw 42 ..." line: "HoverID" and "tex" number differ..... I assume they would have to be the same pointer/ID ? |
Well you can see the draw calls with 6 vtx here. HoveredId is the id of widget when they interact, it has nothnig to do with texture id. |
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, false ); My texture is a static pointer, which gets created on startup of the program and never gets touched by any other code but when the program exits. So this one should be fine. What I'm basically asking is, if anyone else from the community uses DirectX and has a working texture code which he could share, so I get pointed with my nose what I'm missing or what special things have to be done in order to make imgui show the texture. |
I got it working now, so in case someone else gets the same issue, I had to do this in order to make it work:
Thanks for the help :)) |
@MINIONBOTS |
…re to make compability more evident with user's textures (#521)
So there is a problem with the _dx9 sample, it was using an Alpha only texture for the font and the renderer assumed that, hence the:
It works for the font texture but would ignore color in other textures=.
I've changed it to that and changed the font texture to get RGBA instead of Alpha only, which is a waste of resource unfortunately. In a real world scenario, you'd expect
|
So it is a legit problem you pointed here. On one hand I think those _impl files are merely examples of how to integrate ImGui within our own engine and the user is expected to plug their own system. On another hand realistically lots of people use low-level format provided by DX/OpenGL and it is nice if those renderer can be copied and pasted without any modifications (as suggested). So right now I'll adopt the more standard color format for the font texture and assume that people who adapt the renderer to their engine may want to use a Alpha-only texture for the font to save memory. |
Thanks again :) glad it works now |
@ocornut |
Sorry for opening another issue with the same problem, but I cannot make it work and I would appreciate it if someone could tell me why.
...
static LPDIRECT3DTEXTURE9 pTexture = NULL;
if ( D3DXCreateTextureFromFile( g_pd3dDevice, "Z:\alog\minion.jpg" , &pTexture ) != D3D_OK ){
printf("poop\n");
}
...
ImGui::ImageButton((void*)pTexture , ImVec2(236, 325), ImVec2(0,0),ImVec2(100,100),2);
...
All it draws is this, a white empty rectangle:
http://pasteboard.co/1kDzuLNa.png
I tripple checked the pTexture, it is a valid texture and also gets selected correctly (the same pointer) in the render funciton with:
g_pd3dDevice->SetTexture( 0,( LPDIRECT3DTEXTURE9)pcmd->TextureId );
I am honestly lost and need some help, what am I doing wrong ? what am I missing ?
The text was updated successfully, but these errors were encountered: