What is the argument for OpenGL texture units in contrast to regular buffers and uniforms?

I am very new to the OpenGL API and have just discovered textures and how to use them. The generated texture buffers are not connected in the same way that regular uniforms are connected, but instead are used glActiveTextureand then bound, and not just supplied to the shaders through glUniform, as is the case with other constants.

What is the reason for this agreement?

The only reason I can think of is to use the full graphics card and texture processing capabilities, rather than just tying buffers directly. Is this the right reasoning, or is it just a way to implement the API?

The official wiki says no arguments, it just says it's weird: “Binding textures for use in OpenGL is a bit weird” https://www.khronos.org/opengl/wiki/Texture

+4
source share
2 answers

Your question can be interpreted in two ways.

"Why are we binding textures to the context, and not to the shader?"

Because it would make it unnecessarily difficult to have multiple shaders using the same textures. Note that virtually no graphics API directly attaches a texture to the program. Not D3D of any version, not Metal, not even Vulkan.

Textures are resources used by shaders. But they are not part of the shader.

" , ?"

OpenGL : UBOs, SSBOs, . .

- , . , , . , , , .

( AMD GCN , UBO ). .

, . , . API, Vulkan. , , , , .

, .

+5

.

(- ) -. glActiveTexture glBindTexture , glBindBuffer, .

. .

+1

Source: https://habr.com/ru/post/1684566/


All Articles