Thomas King
Thomas King

Reputation: 15

What's the relationship between uniform sampler2D and GL_TEXTURE[NUM] and glGenTexture?

For example, if I want to generate 3 textures using glGenTexture, and there're 3 uniform sampler2D variable in my glsl file, how to bind these 3 textures to these 3 uniform variables, in some specific order?

Upvotes: 0

Views: 207

Answers (1)

datenwolf
datenwolf

Reputation: 162164

There are textures (think of them like "ink cartridges" spilling out pixels.

Thee are texture units, think of them like slots into which you can plug the texture cartridges.

There are samplers which are kind of like small hoses that can be connected to the texture units.


A texture unit which you want to use with the following commands is selected using glActiveTexture. By calling glBindTexture a "texture cartridge" is plugged into the unit. By setting the numeric value of a sampler uniform to the number of the texture unit you connect it to that texture unit to take its pixels from.

Upvotes: 2

Related Questions