[Interest] How to use serveral textures in a QSGSimpleMaterialShader

Till Oliver Knoll till.oliver.knoll at gmail.com
Thu Jul 24 10:00:51 CEST 2014


Am 24.07.2014 um 09:28 schrieb Till Oliver Knoll <till.oliver.knoll at gmail.com>:

> ...
> In recent (OpenGL >= 4.1?) shader versions there is also a "layout" (or "location") qualifier, so you can save the call to glUniform1i - but the exact syntax escapes me right now.

From the "OpenGL SuperBible":

layout (binding = 0) uniform sampler2D foo;
layout (binding = 1) uniform sampler2D bar;
etc.

This is the preferred way of assigning sampler uniforms to texture units (the "binding" values in the shader code above refer off course to the texture units that you "activated" (glActiveTexture) previously before "binding" your textures in your application).

Cheers,
  Oliver


More information about the Interest mailing list