Graphics Programs Reference
In-Depth Information
This is done by calling the method GLES20.glBindTexture . This method
takes two arguments. The first argument is the texture type, defined as con-
stants— GLES20.GL_TEXTURE_2D and GLES20.GL_TEXTURE_CUBE_MAP .
The second argument is the texture id corresponding to a texture object.
Finally, after generating a texture object and binding it, load the image data. To do so,
call the method GLUtils.texImage2D . This method has three overloaded ver-
sions. The one we use takes four arguments— int type , int level , Bitmap
bitmap, and int border . The type argument specifies the texture type. The
level argument specifies the mipmap level to load; set this to “0”, which means
mipmap level “0”.
Note Textures have minification and magnification filtering modes
associated with them (when the size of the projected primitive on the
screen is smaller than the size of the texture, minification is caused,
whereas when the size of the projected primitive on the screen is
larger than the size of the texture, magnification is caused). When
the minification and magnification filters are set to GL_NEAREST ,
the specified texture coordinate is used to fetch a single texel ( texel
nearest to the specified texture coordinate) from the texture. This is
known as nearest sampling. When the minification and magnifica-
tion filters are set to GL_LINEAR, the specified texture coordinate
is used to fetch a bilinear sample (average of four texels ) from the
texture about the texture coordinate.
Nearest sampling can produce visual artifacts when a texture is
wrapped (around a surface) by the interpolation of texture coordin-
ates from one vertex to another. Mipmapping is the solution to avoid
this artifact.
The idea behind mipmapping is to build a chain of images known
as a mipmap chain. The mipmap chain begins with the originally
specified image (mipmap level “0”), then continues with each sub-
sequent image being one-half as large in each dimension as the one
before it. This chain continues until we reach a single 1 x 1 texture
at the bottom of the chain.
To learn more about such advanced OpenGL ES 2.0 concepts, read
OpenGL®ES 2.0 Programming Guide by Aaftab Munshi, Dan
Search WWH ::




Custom Search