Graphics Programs Reference
In-Depth Information
3, GLES20.GL_FLOAT, false, 12, _planeVFB);
2, GLES20.GL_FLOAT, false, 8, _planeTFB);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 6,
The subsequent call to glBindTexture binds the active texture to its texture type.
Finally, to make this texture ready for use with the shader program , call glUni-
form1i and pass it the sampler location as an argument, and an additional argument
specifying the number of current texture (in a zero-based manner). So, for the first
texture used, this value is “0”.
The built-in function texture2D in the fragment shader ( Listing 5-6 ) is used to
fetch from the texture map. It takes the sampler2D uniform and vec2 texture co-
ordinate as arguments. This function returns a vec4 , representing the color fetched
from the texture map. If the format of the texture is RGB, then the vec4 returned is
(R, G, B, 1.0) . If this format is RGBA, then the vec4 returned is (R, G,
B, A) .
Using Texture and Color
Along with the color ( vec4 ) fetched from the texture map, we can also use addition-
al colors ( Figure 5-5 ) with the rendered object. Inside the fragment shader, you can
create a color represented as a variable of type vec4 . Then, you can add this color
to the texture color.
Search WWH ::

Custom Search