Skip to content
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

ImGUI::Image Problems with DirectX11 #1004

Closed
Throbbing opened this issue Feb 2, 2017 · 3 comments
Closed

ImGUI::Image Problems with DirectX11 #1004

Throbbing opened this issue Feb 2, 2017 · 3 comments

Comments

@Throbbing
Copy link

The ImGui::Image function can correctly show SRV created from file(D3DX11GetImageInfoFromFileA ) .
image

However .when I create a manual SRV. the **ImGui::Image ** show nothing.

`
D3D11_TEXTURE2D_DESC td;
	ZeroMemory(&td, sizeof(td));
	td.Usage = D3D11_USAGE_DEFAULT;
	td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
	td.Width = 600;
	td.Height = 400;
	td.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	td.MipLevels = 1;
	td.ArraySize = 1;
	td.MiscFlags = 0;
	td.CPUAccessFlags = 0;
	td.SampleDesc.Count = 1;
	td.SampleDesc.Quality = 0;

D3D11_SUBRESOURCE_DATA sd;
sd.pSysMem = dd;
sd.SysMemPitch = 600*sizeOF(DXGI_FORMAT_R32G32B32A32_FLOAT);
HR(jmxREX::hw.d3dDevice->CreateTexture2D(&td, &sd, &mGameWndImage.tex));


D3D11_SHADER_RESOURCE_VIEW_DESC srvd;
ZeroMemory(&srvd, sizeof(srvd));
srvd.Format = td.Format;
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvd.Texture2D.MostDetailedMip = 0;
srvd.Texture2D.MipLevels = 1;
HR(jmxREX::hw.d3dDevice->CreateShaderResourceView(mGameWndImage.tex, &srvd, &mGameWndImage.srv));`

image
But by the NSight, I found that the SRV is created successfully and filled expected color.
image
image

What is Wrong?

@ocornut
Copy link
Owner

ocornut commented Feb 2, 2017

This is mostly a DX11 question, not an ImGui question.

The only thing ImGui::Image() does it store your ImTextureId parameter and then emit vertices.
The rendering details are left to the rendering loop and are DirectX11 details.

If you can suggest a way to improve the DX11 example code to naturally cover most use cases, a patch is welcome. If you have build your own engine over DX11 you should probably change your use of ImTextureId to pass in higher level primitives that just a ID3D11ShaderResourceView* as imgui_impl_dx11.cpp does. I don't know enough about DX11 to imagine all possible use cases.

@Throbbing
Copy link
Author

@ocornut
Oh. It is my problem...
When i fill the SRV, I neglect the BlendState and set the alpha channel of texture '0',It means that the whole SRV is transparent for DX11 .
I have solved it.Thank you for you reply

@ocornut
Copy link
Owner

ocornut commented Sep 20, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants