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

GL_TEXTURE_2D_ARRAY layer as ImGui::Image #3198

Closed
NukeBird opened this issue May 5, 2020 · 10 comments
Closed

GL_TEXTURE_2D_ARRAY layer as ImGui::Image #3198

NukeBird opened this issue May 5, 2020 · 10 comments

Comments

@NukeBird
Copy link

NukeBird commented May 5, 2020

Is it possible to show specific layer of GL_TEXTURE_2D_ARRAY using ImGui::Image?
If no, is here any alternatives?

@NukeBird NukeBird changed the title GL_TEXTURE_2D_ARRAY as ImGui::Image GL_TEXTURE_2D_ARRAY layer as ImGui::Image May 5, 2020
@ocornut
Copy link
Owner

ocornut commented May 5, 2020

Linking to #2489

@ocornut
Copy link
Owner

ocornut commented May 8, 2020

@NukeBird Please clarify how/why this is something you asked about?
Also see if #2489 is a suitable thread to move the discussion to or not.

@NukeBird
Copy link
Author

NukeBird commented May 9, 2020

Hello @ocornut

Context is simple - I'm writing editor for my ES 3.0 engine and I decided to store textures in texture array atlases to reduce texture switching as much as possible. So I need a handy widget to visualize what's going on inside of my atlases

#2489 looks interesting, but I'm unsure if it canl help (need to go deeper into details). Theoretically third coordinate stands for layer number, but idk if it will be possible to look at mips for each layer too (if present)

@NukeBird
Copy link
Author

NukeBird commented May 9, 2020

Author of 2489 says that it is possible to render layers of texture arrays though, gotta test it in ES 3.0 mode

@NukeBird
Copy link
Author

NukeBird commented May 9, 2020

OK, this pull request sounds good. We can move discussion

@NukeBird NukeBird closed this as completed May 9, 2020
@ocornut
Copy link
Owner

ocornut commented May 9, 2020

If all you need is to render them occasionally, it feels it may be easier to pass in callbacks with info for your renderer to switch shaders and pass in a shader than would take the extra coordinates from uniforms instead of vertices (edited)

@hls333555
Copy link

If all you need is to render them occasionally, it feels it may be easier to pass in callbacks with info for your renderer to switch shaders and pass in a shader than would take the extra coordinates from uniforms instead of vertices (edited)

Is there any examples or code snippets which I can refer to? I don't quite know how to achieve this. Thanks a lot!

@NukeBird
Copy link
Author

@hls333555 I didn't test it myself, but you can try to pass glTextureView. Like you can treat specific layer of GL_TEXTURE_2D_ARRAY as GL_TEXTURE_2D

@hls333555
Copy link

Thanks for NukeBird's advice! For anybody who wants to achieve this, here's the sample code:

// Be sure to call the following after originTexture being created and initialized properly
glGenTextures(arraySize, textureViews);
for (int32_t i = 0; i < arraySize; ++i)
{
    glTextureView(textureViews[i], GL_TEXTURE_2D, originTexture, format, 0, 1, i, 1);
}
// Then you can use textureViews[index] as usual Texture ID

More details: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTextureView.xhtml.

@Platforming-Mayhem
Copy link

@hls333555 do you have any full code examples? I can't seem to get glTextureView to work.

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

No branches or pull requests

4 participants