I
I
IliaNeverov2021-06-19 16:32:36
C++ / C#
IliaNeverov, 2021-06-19 16:32:36

How to bind a texture to a specific VAO?

How to bind a specific texture to a specific VAO, so that one object in the scene displays one texture, and another another?
And one more question - texture units are needed in order to display several textures on one object or for my purpose (and why can only 16 of them be used then)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2021-06-19
@IliaNeverov

It is important to understand that in the days of shaders and megatextures, all this has become a convention.
A texture is just a huge raster that can store "textures" even from all objects in the scene - the question is in coordinates.
glBindTexture() // select a texture
glActiveTexture(GL_TEXTURE0) // attach it to a texture module
glBindTexture() // select another texture
glActiveTexture(GL_TEXTURE1) // attach it to another texture module
Create two samplers in the shader.
sampler2D a;
sampler2Db;
Load texture unit numbers into samplers:
glUniform1i( id_a, 0);
glUniform1i( id_a, 1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question