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

Try to add Array Texture (GL_TEXTURE_2D_ARRAY) support for OpenGL 3 backend but cannot complete it #5033

Closed
eminor1988 opened this issue Feb 18, 2022 · 2 comments

Comments

@eminor1988
Copy link

Version: 1.87
Branch: docking

Backend: imgui_impl_opengl3.cpp

Array Texture:
https://www.khronos.org/opengl/wiki/Array_Texture

I added a macro - "#define IMGUI_IMPL_OPENGL_USE_TEXTURE_2D_ARRAY 1" to switch texture to Array Texture (GL_TEXTURE_2D_ARRAY).

It works fine but the current OpenGL 3 backend code contains GLSL version 120 (OpenGL 2.1) code should not presented in OpenGL 3 core profile, it cannot promise to support Array Texture feature, so I don't know how to deal it.

The GLSL 120 code might be related with the issue - #1513

Other related issue - #3198

Does anyone can help ?


My changes:
changes.patch.txt

@ocornut
Copy link
Owner

ocornut commented Feb 18, 2022

Your backend is actually misnamed and should work with 2.x (as per #1900, in particular #1900 (comment))

Up to you how to want to support this. I suppose users of IMGUI_IMPL_OPENGL_USE_TEXTURE_2D_ARRAY won't use 2.X anyway. Either way I don't think we would merge a PR like that into the official backend, seems unnecessary. As highlighted in #3198 if you want to render your own stuff from texture array use ImDrawList callback to temporarily change the state of the renderer.

@eminor1988
Copy link
Author

Got it, I will try to workaround it by the callback solution.

Other possible solution to me:

  1. Just Copy/Blit single layer of GL_TEXTURE_2D_ARRAY array texture into a GL_TEXTURE_2D texture, but it need additional cost (GPU/VRAM) to copy the texture and determine when to release the copied texture (become non-immediate-mode style).
  2. Use glTextureView but it requires OpenGL 4.3, so it cannot be used it in WebGL 2.

Thanks.

@ocornut ocornut closed this as completed Feb 21, 2022
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

2 participants