WebGL Textures & Vertices

Beginner's Guide

Page Sixty Eight

WebGL API uniformi(WebGLUniformLocation, Number)

Step 1 method setImage() calls the WebGL method uniformi(WebGLUniformLocation, Number) which assigns a texture unit to a sampler uniform in the shader. sampler2D provides access to texture data within the shader. The following listing associates the sampler2D in the shader with the entity's texture unit number. If the entity's WebGLTexture has fully initialized, then the shader may process the texture after the following call. However GLEntity activates the texture unit, then assigns texture data and settings afterward. Either way the specified sampler processes our texture. The online example Change Textures, calls uniformi() to quickly change the texture on display.


Listing 69: WebGL API uniform1i(WebGLUniformLocation, Number)

WebGL Beginner's Guide Introduction WebGL Beginner's Guide
Copyright © 2015 Seven Thunder Software. All Rights Reserved.