JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
11.05k stars 2.81k forks source link

Does OpenGL support Layout Binding like Vulkan? #224

Open engineer1109 opened 3 years ago

engineer1109 commented 3 years ago

Jusk like: layout (binding = 0) uniform sampler2DArray sampler;

layout (binding = 1) uniform UBO { mat4 model; vec4 view; } ubo;

JoeyDeVries commented 3 years ago

Yep, see https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL) in the Binding Points section. This is core since OpenGL 4.2.

engineer1109 commented 3 years ago

@JoeyDeVries Thanks for your responding. So webgl2/opengles 3.0 cannot support the binding ?

And another question: Opengl has the max bindtexture numbers : 32. How can I use unlimited textures like vulkan in OpenGL?

JoeyDeVries commented 3 years ago

Not sure on WebGL2/GLES3.0. You'll have to look that up.

You can put multiple textures in one texture (like they do for sprite animation), or use the (more recommended) 2D texture array approach.

engineer1109 commented 3 years ago

So is there any idea about 3D texture arrays?

JoeyDeVries commented 3 years ago

2D texture array you can basically see as a 3D texture with lots of 2D slices. Not sure a 3D texture array exists if that's what you're specifically looking for, but if you need more than 32 3D textures you'll probably blow up your GPU memory anyways so don't think there's too many use cases for that.